mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
rename iterable assertion functions to new schema in api-infix
cannot rename all files because of git mv incapabilities. Would loose history otherwise.
This commit is contained in:
@@ -5,7 +5,7 @@ import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
|
||||
object IterableAllExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableAllExpectationsSpec(
|
||||
object IterableToHaveNextAndAllExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAllExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndAll),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndAll).withNullableSuffix()
|
||||
) {
|
||||
@@ -7,21 +7,21 @@ import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.IterableAnyExpectationsSpec.Companion as C
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.IterableToHaveNextAndAnyExpectationsSpec.Companion as C
|
||||
|
||||
class IterableAnyExpectationsSpec : Spek({
|
||||
class IterableToHaveNextAndAnyExpectationsSpec : Spek({
|
||||
include(PredicateSpec)
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
include(SequenceSpec)
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableAnyExpectationsSpec(
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndAny),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndAny).withNullableSuffix(),
|
||||
"[Atrium][Predicate] "
|
||||
)
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableAnyExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
functionDescription to C::toContainEntry,
|
||||
(functionDescription to C::toContainNullableEntry).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
@@ -29,14 +29,14 @@ class IterableAnyExpectationsSpec : Spek({
|
||||
|
||||
// TODO 0.19.0 #722 this will differ once we don't implement the same behaviour for toContain and none
|
||||
// that's fine and we can simply remove this test here
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableAnyExpectationsSpec(
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
shortcutDescription to C::toContainEntryShortcut,
|
||||
(shortcutDescription to C::toContainNullableEntryShortcut).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
// TODO move to own SequenceSpec if we really need this (maybe we can also just delete it?)
|
||||
object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableAnyExpectationsSpec(
|
||||
object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
getToContainSequencePair(),
|
||||
getToContainNullableSequencePair().withNullableSuffix(),
|
||||
"[Atrium][Sequence] "
|
||||
@@ -5,13 +5,13 @@ import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.IterableNoneExpectationsSpec.Companion as C
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.IterableToHaveNextAndNoneExpectationsSpec.Companion as C
|
||||
|
||||
class IterableNoneExpectationsSpec : Spek({
|
||||
class IterableToHaveNextAndNoneExpectationsSpec : Spek({
|
||||
include(PredicateSpec)
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableNoneExpectationsSpec(
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndNoneExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndNone),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndNone).withNullableSuffix(),
|
||||
"[Atrium][Predicate] "
|
||||
@@ -19,7 +19,7 @@ class IterableNoneExpectationsSpec : Spek({
|
||||
|
||||
// TODO 0.19.0 #722 this will differ once we don't implement the same behaviour for contains and none
|
||||
// that's fine and we can simply remove this test here
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableNoneExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndNoneExpectationsSpec(
|
||||
functionDescription to C::notToContainFun,
|
||||
(functionDescription to C::notToContainNullableFun).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
@@ -241,6 +241,7 @@ infix fun <E, T : Iterable<E>> Expect<T>.containsNot(expected: E): Expect<T> =
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.containsNot(values: Values<E>): Expect<T> =
|
||||
it containsNot o the values
|
||||
|
||||
//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.
|
||||
@@ -254,6 +255,7 @@ infix fun <E, T : Iterable<E>> Expect<T>.containsNot(values: Values<E>): Expect<
|
||||
infix fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.min(@Suppress("UNUSED_PARAMETER") o: o): 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
|
||||
@@ -267,6 +269,7 @@ infix fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.min(assertionCreator: E
|
||||
_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.
|
||||
@@ -280,6 +283,7 @@ infix fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.min(assertionCreator: E
|
||||
infix fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.max(@Suppress("UNUSED_PARAMETER") o: o): 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
|
||||
@@ -359,6 +363,7 @@ infix fun <E, T : Iterable<E>> Expect<T>.hasNot(@Suppress("UNUSED_PARAMETER") ne
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.contains(@Suppress("UNUSED_PARAMETER") noDuplicates: noDuplicates): Expect<T> =
|
||||
_logicAppend { containsNoDuplicates(::identity) }
|
||||
|
||||
//TODO 0.18.0 move to iterableExpectations.kt
|
||||
/**
|
||||
* Turns `Expect<E, T : Iterable<E>>` into `Expect<List<E>`.
|
||||
*
|
||||
@@ -373,6 +378,7 @@ infix fun <E, T : Iterable<E>> Expect<T>.asList(
|
||||
@Suppress("UNUSED_PARAMETER") o: o
|
||||
): 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].
|
||||
|
||||
@@ -0,0 +1,334 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.Entries
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.Values
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.*
|
||||
import ch.tutteli.atrium.logic.creating.iterable.contains.IterableLikeContains
|
||||
import ch.tutteli.atrium.logic.creating.iterable.contains.searchbehaviours.NoOpSearchBehaviour
|
||||
import ch.tutteli.atrium.logic.creating.iterable.contains.searchbehaviours.NotSearchBehaviour
|
||||
import ch.tutteli.atrium.logic.creating.iterable.contains.steps.NotCheckerStep
|
||||
import ch.tutteli.atrium.logic.creating.typeutils.IterableLike
|
||||
import ch.tutteli.kbox.identity
|
||||
|
||||
/**
|
||||
* Starts a sophisticated `toContain` assertion building process based on this [Expect].
|
||||
*
|
||||
* @param o The filler object [o].
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.toContain(
|
||||
@Suppress("UNUSED_PARAMETER") o: o
|
||||
): IterableLikeContains.EntryPointStep<E, T, NoOpSearchBehaviour> = _logic.builderContainsInIterableLike(::identity)
|
||||
|
||||
/**
|
||||
* Starts a sophisticated `toContain` assertion building process based on this [Expect] and already chooses a
|
||||
* [NotCheckerStep].
|
||||
*
|
||||
* @param o The filler object [o].
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.notToContain(
|
||||
@Suppress("UNUSED_PARAMETER") o: o
|
||||
): NotCheckerStep<E, T, NotSearchBehaviour> = _logic.builderContainsNotInIterableLike(::identity)
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) contains the [expected] value.
|
||||
*
|
||||
* It is a shortcut for `toContain o inAny order atLeast 1 value expected`
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.toContain(expected: E): Expect<T> =
|
||||
it toContain o inAny order atLeast 1 value expected
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) contains the expected [values].
|
||||
*
|
||||
* It is a shortcut for `toContain o inAny order atLeast 1 the values(...)`
|
||||
*
|
||||
* Notice, that it does not search for unique matches. Meaning, if the iterable is `setOf('a', 'b')` and
|
||||
* [Values] is defined as `values("a", "a")`, then both match,
|
||||
* even though they match the same sequence in the input of the search.
|
||||
* Use an option such as [atLeast], [atMost] and [exactly] to control the number of occurrences you expect.
|
||||
*
|
||||
* Meaning you might want to use:
|
||||
* toContain o inAny order exactly 2 value 'a'`
|
||||
* instead of:
|
||||
* `toContain values('a', 'a')`
|
||||
*
|
||||
* @param values The values which are expected to be contained within the [Iterable]
|
||||
* -- use the function `values(t, ...)` to create a [Values].
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.toContain(values: Values<E>): Expect<T> =
|
||||
it toContain o inAny order atLeast 1 the values
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) contains an entry holding the
|
||||
* assertions created by [assertionCreatorOrNull] or an entry which is `null` in case [assertionCreatorOrNull]
|
||||
* is defined as `null`.
|
||||
*
|
||||
* It is a shortcut for `toContain o inAny order atLeast 1 entry assertionCreatorOrNull`
|
||||
*
|
||||
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
|
||||
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
|
||||
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toContain(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
it toContain o inAny order atLeast 1 entry assertionCreatorOrNull
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) contains an entry holding the
|
||||
* assertions created by [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] or an entry
|
||||
* which is `null` in case [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull]
|
||||
* is defined as `null` -- likewise an entry (can be the same) is searched for each of the
|
||||
* [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls].
|
||||
*
|
||||
* It is a shortcut for `toContain o inAny order atLeast 1 the entries({ ... }, ...)`
|
||||
*
|
||||
* @param entries The entries which are expected to be contained within the [Iterable]
|
||||
* -- use the function `entries(t, ...)` to create an [Entries].
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toContain(entries: Entries<E>): Expect<T> =
|
||||
it toContain o inAny order atLeast 1 the entries
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) contains only
|
||||
* the [expected] value.
|
||||
*
|
||||
* It is a shortcut for `toContain o inGiven order and only value expected`
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.toContainExactly(expected: E): Expect<T> =
|
||||
it toContain o inGiven order and only value expected
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) contains only
|
||||
* the expected [values] in the defined order.
|
||||
*
|
||||
* It is a shortcut for `toContain o inGiven order and only the Values(...)`
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param values The values which are expected to be contained within the [Iterable]
|
||||
* -- use the function `values(t, ...)` to create a [Values].
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.toContainExactly(values: Values<E>): Expect<T> =
|
||||
it toContain o inGiven order and only the values
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) contains only an entry holding
|
||||
* the assertions created by [assertionCreatorOrNull] or only one entry which is `null` in case [assertionCreatorOrNull]
|
||||
* is defined as `null`.
|
||||
*
|
||||
* It is a shortcut for `toContain o inGiven order and only entry assertionCreatorOrNull`
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
|
||||
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
|
||||
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toContainExactly(
|
||||
assertionCreatorOrNull: (Expect<E>.() -> Unit)?
|
||||
): Expect<T> = it toContain o inGiven order and only entry assertionCreatorOrNull
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) contains only an entry holding
|
||||
* the assertions created by [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] or
|
||||
* `null` in case [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] is defined as `null`
|
||||
* and likewise an additional entry for each
|
||||
* [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls] (if given)
|
||||
* whereas the entries have to appear in the defined order.
|
||||
*
|
||||
* It is a shortcut for `toContain o inGiven order and only the Entries(...)`
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param entries The entries which are expected to be contained within the [Iterable]
|
||||
* -- use the function `entries(t, ...)` to create an [Entries].
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toContainExactly(entries: Entries<E>): Expect<T> =
|
||||
it toContain o inGiven order and only the entries
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) contains only elements of [expectedIterableLike]
|
||||
* in same order
|
||||
*
|
||||
* It is a shortcut for 'toContain.inOrder.only.elementsOf(anotherList)'
|
||||
*
|
||||
* Notice that a runtime check applies which assures that only [Iterable], [Sequence] or one of the [Array] types
|
||||
* are passed. This function expects [IterableLike] (which is a typealias for [Any]) to avoid cluttering the API.
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
* @throws IllegalArgumentException in case [expectedIterableLike] is not an [Iterable], [Sequence] or one of the [Array] types
|
||||
* or the given [expectedIterableLike] does not have elements (is empty).
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
inline infix fun <reified E, T : Iterable<E>> Expect<T>.toContainExactlyElementsOf(
|
||||
expectedIterableLike: IterableLike
|
||||
): Expect<T> = it toContain o inGiven order and only elementsOf (expectedIterableLike)
|
||||
|
||||
/** Expects that the subject of `this` expectation (an [Iterable]) contains all elements of [expectedIterableLike].
|
||||
*
|
||||
* It is a shortcut for `toContain.inAnyOrder.atLeast(1).elementsOf(expectedIterable)`
|
||||
*
|
||||
* Notice that a runtime check applies which assures that only [Iterable], [Sequence] or one of the [Array] types
|
||||
* are passed. This function expects [IterableLike] (which is a typealias for [Any]) to avoid cluttering the API.
|
||||
*
|
||||
* @param expectedIterableLike The [IterableLike] whose elements are expected to be contained within this [Iterable].
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
* @throws IllegalArgumentException in case [expectedIterableLike] is not an [Iterable], [Sequence] or one of the [Array] types
|
||||
* or the given [expectedIterableLike] does not have elements (is empty).
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
inline infix fun <reified E, T : Iterable<E>> Expect<T>.toContainElementsOf(
|
||||
expectedIterableLike: IterableLike
|
||||
): Expect<T> = it toContain o inAny order atLeast 1 elementsOf expectedIterableLike
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) has at least one element and
|
||||
* that it does not contain the [expected] value.
|
||||
*
|
||||
* It is a shortcut for `notToContain o value expected`
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.notToContain(expected: E): Expect<T> =
|
||||
it notToContain o value expected
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) has at least one element and
|
||||
* that it does not contain the expected [values].
|
||||
*
|
||||
* It is a shortcut for `notToContain o the values(...)`
|
||||
*
|
||||
* @param values The values which should not be contained within the [Iterable]
|
||||
* -- use the function `values(t, ...)` to create a [Values].
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.notToContain(values: Values<E>): Expect<T> =
|
||||
it notToContain o the values
|
||||
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) contains an entry holding
|
||||
* the assertions created by [assertionCreatorOrNull] or an entry which is `null` in case [assertionCreatorOrNull]
|
||||
* is defined as `null`.
|
||||
*
|
||||
* It is a shortcut for `toContain o inAny order atLeast 1 entry assertionCreatorOrNull`
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndAny(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
it toContain o inAny order atLeast 1 entry assertionCreatorOrNull
|
||||
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) has at least one element and
|
||||
* that it either does not contain a single entry which holds all assertions created by [assertionCreatorOrNull] or
|
||||
* that it does not contain a single entry which is `null` in case [assertionCreatorOrNull] is defined as `null`.
|
||||
*
|
||||
* It is a shortcut for `notToContain o entry assertionCreatorOrNull`
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndNone(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
it notToContain o entry assertionCreatorOrNull
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) has at least one element and
|
||||
* that either every element holds all assertions created by the [assertionCreatorOrNull] or
|
||||
* that all elements are `null` in case [assertionCreatorOrNull] is defined as `null`.
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.toHaveNextAndAll(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
_logicAppend { all(::identity, assertionCreatorOrNull) }
|
||||
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) has at least one element.
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.toHave(@Suppress("UNUSED_PARAMETER") next: next): Expect<T> =
|
||||
_logicAppend { hasNext(::identity) }
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) does not have next element.
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.notToHave(@Suppress("UNUSED_PARAMETER") next: next): Expect<T> =
|
||||
_logicAppend { hasNotNext(::identity) }
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (an [Iterable]) does not have duplicate elements.
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.notToContain(@Suppress("UNUSED_PARAMETER") duplicates: duplicates): Expect<T> =
|
||||
_logicAppend { containsNoDuplicates(::identity) }
|
||||
|
||||
@@ -11,31 +11,31 @@ package ch.tutteli.atrium.api.infix.en_GB
|
||||
interface Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about a path being a regular file.
|
||||
* A helper construct to allow expressing expectations about a path being a regular file.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*/
|
||||
object aRegularFile : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about a path being a directory.
|
||||
* A helper construct to allow expressing expectations about a path being a directory.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*/
|
||||
object aDirectory : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about a path being an empty directory.
|
||||
* A helper construct to allow expressing expectations about a path being an empty directory.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*/
|
||||
object anEmptyDirectory : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about a path being a symbolic link.
|
||||
* A helper construct to allow expressing expectations about a path being a symbolic link.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*/
|
||||
object aSymbolicLink : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about a path being absolute.
|
||||
* A helper construct to allow expressing expectations about a path being absolute.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*
|
||||
* @since 0.14.0
|
||||
@@ -43,7 +43,7 @@ object aSymbolicLink : Keyword
|
||||
object absolute : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about a path being relative.
|
||||
* A helper construct to allow expressing expectations about a path being relative.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*
|
||||
* @since 0.14.0
|
||||
@@ -75,7 +75,7 @@ object empty : Keyword
|
||||
object entries : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about path existence.
|
||||
* A helper construct to allow expressing expectations about path existence.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*/
|
||||
object existing : Keyword
|
||||
@@ -125,7 +125,7 @@ object present : Keyword
|
||||
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about a path being readable.
|
||||
* A helper construct to allow expressing expectations about a path being readable.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*/
|
||||
object readable : Keyword
|
||||
@@ -139,21 +139,30 @@ object readable : Keyword
|
||||
object success : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about a path being writable.
|
||||
* A helper construct to allow expressing expectations about a path being writable.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*/
|
||||
object writable : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about a path being executable.
|
||||
* A helper construct to allow expressing expectations about a path being executable.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*/
|
||||
object executable : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing assertions about iterable contains no duplicates.
|
||||
* A helper construct to allow expressing expectations about iterable contains no duplicates.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*
|
||||
* @since 0.14.0
|
||||
*/
|
||||
@Deprecated("Will be removed with 1.0.0 at the latest without replacement")
|
||||
object noDuplicates : Keyword
|
||||
|
||||
/**
|
||||
* A helper construct to allow expressing expectations about duplicates as in `expect(iterable) notToContain duplicates`.
|
||||
* It can be used for a parameterless function so that it has one parameter and thus can be used as infix function.
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
object duplicates : Keyword
|
||||
|
||||
@@ -15,76 +15,76 @@ class IterableAnyExpectationsSpec : Spek({
|
||||
include(ShortcutSpec)
|
||||
include(SequenceSpec)
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableAnyExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::any),
|
||||
fun1(Expect<Iterable<Double?>>::any).withNullableSuffix(),
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndAny),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndAny).withNullableSuffix(),
|
||||
"[Atrium][Predicate] "
|
||||
)
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableAnyExpectationsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair().withNullableSuffix(),
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
getToContainPair(),
|
||||
getToContainNullablePair().withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableAnyExpectationsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair().withNullableSuffix(),
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
getToContainShortcutPair(),
|
||||
getToContainNullableShortcutPair().withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableAnyExpectationsSpec(
|
||||
getContainsSequencePair(),
|
||||
getContainsNullableSequencePair().withNullableSuffix(),
|
||||
object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec(
|
||||
getToContainSequencePair(),
|
||||
getToContainNullableSequencePair().withNullableSuffix(),
|
||||
"[Atrium][Sequence] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 entry" to Companion::containsInAnyOrderEntry
|
||||
fun getToContainPair() =
|
||||
"$toContain $filler $inAnyOrder $atLeast 1 entry" to Companion::toContainInAnyOrderEntry
|
||||
|
||||
private fun containsInAnyOrderEntry(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect contains o inAny order atLeast 1 entry a
|
||||
private fun toContainInAnyOrderEntry(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect toContain o inAny order atLeast 1 entry a
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 entry" to Companion::containsNullableEntry
|
||||
fun getToContainNullablePair() =
|
||||
"$toContain $filler $inAnyOrder $atLeast 1 entry" to Companion::toContainNullableEntry
|
||||
|
||||
private fun containsNullableEntry(expect: Expect<Iterable<Double?>>, a: (Expect<Double>.() -> Unit)?) =
|
||||
expect contains o inAny order atLeast 1 entry a
|
||||
private fun toContainNullableEntry(expect: Expect<Iterable<Double?>>, a: (Expect<Double>.() -> Unit)?) =
|
||||
expect toContain o inAny order atLeast 1 entry a
|
||||
|
||||
private val containsShortcutFun: KFunction2<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::contains
|
||||
private val toContainShortcutFun: KFunction2<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::toContain
|
||||
|
||||
fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntryShortcut
|
||||
fun getToContainShortcutPair() = toContainShortcutFun.name to Companion::toContainInAnyOrderEntryShortcut
|
||||
|
||||
private fun containsInAnyOrderEntryShortcut(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect contains a
|
||||
private fun toContainInAnyOrderEntryShortcut(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect toContain a
|
||||
|
||||
private val containsShortcutNullableFun: KFunction2<Expect<Iterable<Double?>>, (Expect<Double>.() -> Unit)?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::contains
|
||||
private val toContainShortcutNullableFun: KFunction2<Expect<Iterable<Double?>>, (Expect<Double>.() -> Unit)?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::toContain
|
||||
|
||||
fun getContainsNullableShortcutPair() =
|
||||
containsShortcutNullableFun.name to Companion::containsNullableEntryShortcut
|
||||
fun getToContainNullableShortcutPair() =
|
||||
toContainShortcutNullableFun.name to Companion::toContainNullableEntryShortcut
|
||||
|
||||
private fun containsNullableEntryShortcut(
|
||||
private fun toContainNullableEntryShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?
|
||||
) = expect contains a
|
||||
) = expect toContain a
|
||||
|
||||
|
||||
private fun getContainsSequencePair() =
|
||||
"asSequence().${Sequence<*>::asIterable.name}() ${containsShortcutFun.name}" to Companion::containsInAnyOrderEntrySequence
|
||||
private fun getToContainSequencePair() =
|
||||
"asSequence().${Sequence<*>::asIterable.name}() ${toContainShortcutFun.name}" to Companion::toContainInAnyOrderEntrySequence
|
||||
|
||||
private fun containsInAnyOrderEntrySequence(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect._logic.changeSubject.unreported { it.asSequence() } asIterable o contains a
|
||||
private fun toContainInAnyOrderEntrySequence(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect._logic.changeSubject.unreported { it.asSequence() } asIterable o toContain a
|
||||
|
||||
fun getContainsNullableSequencePair() =
|
||||
"asSequence().${Sequence<*>::asIterable.name}() ${containsShortcutNullableFun.name}" to Companion::containsNullableEntrySequence
|
||||
fun getToContainNullableSequencePair() =
|
||||
"asSequence().${Sequence<*>::asIterable.name}() ${toContainShortcutNullableFun.name}" to Companion::toContainNullableEntrySequence
|
||||
|
||||
private fun containsNullableEntrySequence(
|
||||
private fun toContainNullableEntrySequence(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?
|
||||
) = expect._logic.changeSubject.unreported { it.asSequence() } asIterable { it contains a } asIterable o
|
||||
) = expect._logic.changeSubject.unreported { it.asSequence() } asIterable { it toContain a } asIterable o
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
@@ -94,15 +94,15 @@ class IterableAnyExpectationsSpec : Spek({
|
||||
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1 any {}
|
||||
a1 = a1 contains {}
|
||||
a1 = a1 toHaveNextAndAny {}
|
||||
a1 = a1 toContain {}
|
||||
|
||||
a1b = a1b any {}
|
||||
a1b = a1b any null
|
||||
a1b = a1b contains {}
|
||||
a1b = a1b contains (null as Double?)
|
||||
a1b = a1b toHaveNextAndAny {}
|
||||
a1b = a1b toHaveNextAndAny null
|
||||
a1b = a1b toContain {}
|
||||
a1b = a1b toContain (null as Double?)
|
||||
|
||||
star = star any {}
|
||||
star = star contains {}
|
||||
star = star toHaveNextAndAny {}
|
||||
star = star toContain {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,76 +4,76 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsInAnyOrderAtLeast1ElementsOfExpectationsSpec : Spek({
|
||||
class IterableToContainInAnyOrderAtLeast1ElementsOfExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
include(BuilderIterableLikeToIterableSpec)
|
||||
include(ShortcutIterableLikeToIterableSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderAtLeast1ValuesExpectationsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
getToContainPair(),
|
||||
getToContainNullablePair(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderAtLeast1ValuesExpectationsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair(),
|
||||
getToContainShortcutPair(),
|
||||
getToContainNullableShortcutPair(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
object BuilderIterableLikeToIterableSpec : ch.tutteli.atrium.specs.integration.IterableLikeToIterableSpec<List<Int>>(
|
||||
"contains o inAny order atLeast 1 elementsOf",
|
||||
"toContain o inAny order atLeast 1 elementsOf",
|
||||
listOf(1, 2),
|
||||
{ input -> it contains o inAny order atLeast 1 elementsOf input }
|
||||
{ input -> it toContain o inAny order atLeast 1 elementsOf input }
|
||||
)
|
||||
|
||||
object ShortcutIterableLikeToIterableSpec : ch.tutteli.atrium.specs.integration.IterableLikeToIterableSpec<List<Int>>(
|
||||
"containsElementsOf",
|
||||
"toContainElementsOf",
|
||||
listOf(1, 2),
|
||||
{ input -> it containsElementsOf input }
|
||||
{ input -> it toContainElementsOf input }
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderElementsOf" to Companion::containsValues
|
||||
fun getToContainPair() =
|
||||
"$toContain $filler $inAnyOrder $atLeast 1 $inAnyOrderElementsOf" to Companion::toContainValues
|
||||
|
||||
private fun containsValues(
|
||||
private fun toContainValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> = expect contains o inAny order atLeast 1 elementsOf listOf(a, *aX)
|
||||
): Expect<Iterable<Double>> = expect toContain o inAny order atLeast 1 elementsOf listOf(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderElementsOf" to Companion::containsNullableValues
|
||||
fun getToContainNullablePair() =
|
||||
"$toContain $filler $inAnyOrder $atLeast 1 $inAnyOrderElementsOf" to Companion::toContainNullableValues
|
||||
|
||||
private fun containsNullableValues(
|
||||
private fun toContainNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> = expect contains o inAny order atLeast 1 elementsOf sequenceOf(a, *aX)
|
||||
): Expect<Iterable<Double?>> = expect toContain o inAny order atLeast 1 elementsOf sequenceOf(a, *aX)
|
||||
|
||||
private val containsElementsOfShortcutFun: KFunction2<Expect<Iterable<Double>>, Iterable<Double>, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::containsElementsOf
|
||||
private val toContainElementsOfShortcutFun: KFunction2<Expect<Iterable<Double>>, Iterable<Double>, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::toContainElementsOf
|
||||
|
||||
private fun getContainsShortcutPair() = containsElementsOfShortcutFun.name to Companion::containsInAnyOrderShortcut
|
||||
private fun getToContainShortcutPair() = toContainElementsOfShortcutFun.name to Companion::toContainInAnyOrderShortcut
|
||||
|
||||
private fun containsInAnyOrderShortcut(
|
||||
private fun toContainInAnyOrderShortcut(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> = expect containsElementsOf arrayOf(a, *aX)
|
||||
): Expect<Iterable<Double>> = expect toContainElementsOf arrayOf(a, *aX)
|
||||
|
||||
private val containsElementsOfNullableShortcutFun: KFunction2<Expect<Iterable<Double?>>, Iterable<Double?>, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::containsElementsOf
|
||||
private val toContainElementsOfNullableShortcutFun: KFunction2<Expect<Iterable<Double?>>, Iterable<Double?>, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::toContainElementsOf
|
||||
|
||||
private fun getContainsNullableShortcutPair() = containsElementsOfNullableShortcutFun.name to Companion::containsInAnyOrderNullableShortcut;
|
||||
private fun getToContainNullableShortcutPair() = toContainElementsOfNullableShortcutFun.name to Companion::toContainInAnyOrderNullableShortcut;
|
||||
|
||||
private fun containsInAnyOrderNullableShortcut(
|
||||
private fun toContainInAnyOrderNullableShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> = expect containsElementsOf sequenceOf(a, *aX).asIterable()
|
||||
): Expect<Iterable<Double?>> = expect toContainElementsOf sequenceOf(a, *aX).asIterable()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,70 +4,70 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsInAnyOrderAtLeast1EntriesExpectationsSpec : Spek({
|
||||
class IterableToContainInAnyOrderAtLeast1EntriesExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderAtLeast1EntriesExpectationsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
getToContainPair(),
|
||||
getToContainNullablePair(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderAtLeast1EntriesExpectationsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair(),
|
||||
getToContainShortcutPair(),
|
||||
getToContainNullableShortcutPair(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderEntries" to Companion::containsInAnyOrderEntries
|
||||
fun getToContainPair() =
|
||||
"$toContain $filler $inAnyOrder $atLeast 1 $inAnyOrderEntries" to Companion::toContainInAnyOrderEntries
|
||||
|
||||
private fun containsInAnyOrderEntries(
|
||||
private fun toContainInAnyOrderEntries(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order atLeast 1 entry a
|
||||
else expect contains o inAny order atLeast 1 the entries(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inAny order atLeast 1 entry a
|
||||
else expect toContain o inAny order atLeast 1 the entries(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderEntries" to Companion::containsNullableEntries
|
||||
fun getToContainNullablePair() =
|
||||
"$toContain $filler $inAnyOrder $atLeast 1 $inAnyOrderEntries" to Companion::toContainNullableEntries
|
||||
|
||||
private fun containsNullableEntries(
|
||||
private fun toContainNullableEntries(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order atLeast 1 entry a
|
||||
else expect contains o inAny order atLeast 1 the entries(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inAny order atLeast 1 entry a
|
||||
else expect toContain o inAny order atLeast 1 the entries(a, *aX)
|
||||
|
||||
|
||||
private val containsShortcutFun: KFunction2<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::contains
|
||||
private val toContainShortcutFun: KFunction2<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::toContain
|
||||
|
||||
fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntriesShortcut
|
||||
fun getToContainShortcutPair() = toContainShortcutFun.name to Companion::toContainInAnyOrderEntriesShortcut
|
||||
|
||||
private fun containsInAnyOrderEntriesShortcut(
|
||||
private fun toContainInAnyOrderEntriesShortcut(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains a
|
||||
else expect contains entries(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain a
|
||||
else expect toContain entries(a, *aX)
|
||||
|
||||
private val containsEntriesFun: KFunction2<Expect<Iterable<Double?>>, (Expect<Double>.() -> Unit)?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::contains
|
||||
private val toContainEntriesFun: KFunction2<Expect<Iterable<Double?>>, (Expect<Double>.() -> Unit)?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::toContain
|
||||
|
||||
fun getContainsNullableShortcutPair() = containsEntriesFun.name to Companion::containsNullableEntriesShortcut
|
||||
fun getToContainNullableShortcutPair() = toContainEntriesFun.name to Companion::toContainNullableEntriesShortcut
|
||||
|
||||
private fun containsNullableEntriesShortcut(
|
||||
private fun toContainNullableEntriesShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains a
|
||||
else expect contains entries(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain a
|
||||
else expect toContain entries(a, *aX)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,72 +4,72 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsInAnyOrderAtLeast1ValuesExpectationsSpec : Spek({
|
||||
class IterableToContainInAnyOrderAtLeast1ValuesExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderAtLeast1ValuesExpectationsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
getToContainPair(),
|
||||
getToContainNullablePair(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderAtLeast1ValuesExpectationsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair(),
|
||||
getToContainShortcutPair(),
|
||||
getToContainNullableShortcutPair(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderValues" to Companion::containsValues
|
||||
fun getToContainPair() =
|
||||
"$toContain $filler $inAnyOrder $atLeast 1 $inAnyOrderValues" to Companion::toContainValues
|
||||
|
||||
private fun containsValues(
|
||||
private fun toContainValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order atLeast 1 value a
|
||||
else expect contains o inAny order atLeast 1 the values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inAny order atLeast 1 value a
|
||||
else expect toContain o inAny order atLeast 1 the values(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderValues" to Companion::containsNullableValues
|
||||
fun getToContainNullablePair() =
|
||||
"$toContain $filler $inAnyOrder $atLeast 1 $inAnyOrderValues" to Companion::toContainNullableValues
|
||||
|
||||
private fun containsNullableValues(
|
||||
private fun toContainNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order atLeast 1 value a
|
||||
else expect contains o inAny order atLeast 1 the values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inAny order atLeast 1 value a
|
||||
else expect toContain o inAny order atLeast 1 the values(a, *aX)
|
||||
|
||||
|
||||
private val containsFun: KFunction2<Expect<Iterable<Double>>, Double, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::contains
|
||||
private val toContainFun: KFunction2<Expect<Iterable<Double>>, Double, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::toContain
|
||||
|
||||
fun getContainsShortcutPair() = containsFun.name to Companion::containsValuesShortcut
|
||||
fun getToContainShortcutPair() = toContainFun.name to Companion::toContainValuesShortcut
|
||||
|
||||
private fun containsValuesShortcut(
|
||||
private fun toContainValuesShortcut(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains a
|
||||
else expect contains values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain a
|
||||
else expect toContain values(a, *aX)
|
||||
|
||||
|
||||
private val containsNullableFun: KFunction2<Expect<Iterable<Double?>>, Double?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::contains
|
||||
private val toContainNullableFun: KFunction2<Expect<Iterable<Double?>>, Double?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::toContain
|
||||
|
||||
fun getContainsNullableShortcutPair() = containsNullableFun.name to Companion::containsNullableValuesShortcut
|
||||
fun getToContainNullableShortcutPair() = toContainNullableFun.name to Companion::toContainNullableValuesShortcut
|
||||
|
||||
private fun containsNullableValuesShortcut(
|
||||
private fun toContainNullableValuesShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains a
|
||||
else expect contains values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain a
|
||||
else expect toContain values(a, *aX)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,39 +3,39 @@ package ch.tutteli.atrium.api.infix.en_GB
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
|
||||
class IterableContainsInAnyOrderOnlyElementsOfExpectationsSpec : Spek({
|
||||
class IterableToContainInAnyOrderOnlyElementsOfExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(BuilderIterableLikeToIterableSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderOnlyValuesExpectationsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair()
|
||||
getToContainPair(),
|
||||
getToContainNullablePair()
|
||||
)
|
||||
|
||||
object BuilderIterableLikeToIterableSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableLikeToIterableSpec<List<Int>>(
|
||||
"contains o inAny order but only elementsOf",
|
||||
"toContain o inAny order but only elementsOf",
|
||||
listOf(1, 2),
|
||||
{ input -> it contains o inAny order but only elementsOf input }
|
||||
{ input -> it toContain o inAny order but only elementsOf input }
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf" to Companion::getContainsValues
|
||||
fun getToContainPair() =
|
||||
"$toContain $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf" to Companion::getToContainValues
|
||||
|
||||
private fun getContainsValues(
|
||||
private fun getToContainValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> = expect contains o inAny order but only elementsOf listOf(a, *aX)
|
||||
): Expect<Iterable<Double>> = expect toContain o inAny order but only elementsOf listOf(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf" to Companion::getContainsNullableValues
|
||||
fun getToContainNullablePair() =
|
||||
"$toContain $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf" to Companion::getToContainNullableValues
|
||||
|
||||
private fun getContainsNullableValues(
|
||||
private fun getToContainNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> = expect contains o inAny order but only elementsOf sequenceOf(a, *aX)
|
||||
): Expect<Iterable<Double?>> = expect toContain o inAny order but only elementsOf sequenceOf(a, *aX)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,80 +4,80 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsInOrderOnlyElementsOfExpectationsSpec : Spek({
|
||||
class IterableToContainInOrderOnlyElementsOfExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
include(BuilderIterableLikeToIterableSpec)
|
||||
include(ShortcutIterableLikeToIterableSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToContainInOrderOnlyValuesExpectationsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
getToContainPair(),
|
||||
getToContainNullablePair(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToContainInOrderOnlyValuesExpectationsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair(),
|
||||
getToContainShortcutPair(),
|
||||
getToContainNullableShortcutPair(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
object BuilderIterableLikeToIterableSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableLikeToIterableSpec<List<Int>>(
|
||||
"contains o inGiven order and only elementsOf",
|
||||
"toContain o inGiven order and only elementsOf",
|
||||
listOf(1, 2),
|
||||
{ input -> it contains o inGiven order and only elementsOf input }
|
||||
{ input -> it toContain o inGiven order and only elementsOf input }
|
||||
)
|
||||
|
||||
object ShortcutIterableLikeToIterableSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableLikeToIterableSpec<List<Int>>(
|
||||
"containsExactlyElementsOf",
|
||||
"toContainExactlyElementsOf",
|
||||
listOf(1, 2),
|
||||
{ input -> it containsExactlyElementsOf input }
|
||||
{ input -> it toContainExactlyElementsOf input }
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderElementsOf" to Companion::containsInOrderOnlyValues
|
||||
fun getToContainPair() =
|
||||
"$toContain $filler $inOrder $andOnly $inOrderElementsOf" to Companion::toContainInOrderOnlyValues
|
||||
|
||||
private fun containsInOrderOnlyValues(
|
||||
private fun toContainInOrderOnlyValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> = expect contains o inGiven order and only elementsOf listOf(a, *aX)
|
||||
): Expect<Iterable<Double>> = expect toContain o inGiven order and only elementsOf listOf(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderElementsOf" to Companion::containsInOrderOnlyNullableValues
|
||||
fun getToContainNullablePair() =
|
||||
"$toContain $filler $inOrder $andOnly $inOrderElementsOf" to Companion::toContainInOrderOnlyNullableValues
|
||||
|
||||
private fun containsInOrderOnlyNullableValues(
|
||||
private fun toContainInOrderOnlyNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> = expect contains o inGiven order and only elementsOf sequenceOf(a, *aX)
|
||||
): Expect<Iterable<Double?>> = expect toContain o inGiven order and only elementsOf sequenceOf(a, *aX)
|
||||
|
||||
private val containsExactlyElementsOfShortcutFun: KFunction2<Expect<Iterable<Double>>, Iterable<Double>, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::containsExactlyElementsOf
|
||||
private val toContainExactlyElementsOfShortcutFun: KFunction2<Expect<Iterable<Double>>, Iterable<Double>, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::toContainExactlyElementsOf
|
||||
|
||||
private fun getContainsShortcutPair() =
|
||||
containsExactlyElementsOfShortcutFun.name to Companion::containsExactlyElementsOfShortcut
|
||||
private fun getToContainShortcutPair() =
|
||||
toContainExactlyElementsOfShortcutFun.name to Companion::toContainExactlyElementsOfShortcut
|
||||
|
||||
private fun containsExactlyElementsOfShortcut(
|
||||
private fun toContainExactlyElementsOfShortcut(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> = expect containsExactlyElementsOf arrayOf(a, *aX)
|
||||
): Expect<Iterable<Double>> = expect toContainExactlyElementsOf arrayOf(a, *aX)
|
||||
|
||||
private val containsExactlyElementsOfNullableShortcutFun: KFunction2<Expect<Iterable<Double?>>, Iterable<Double?>, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::containsExactlyElementsOf
|
||||
private val toContainExactlyElementsOfNullableShortcutFun: KFunction2<Expect<Iterable<Double?>>, Iterable<Double?>, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::toContainExactlyElementsOf
|
||||
|
||||
private fun getContainsNullableShortcutPair() =
|
||||
containsExactlyElementsOfNullableShortcutFun.name to Companion::containsExactlyElementsOfNullableShortcut;
|
||||
private fun getToContainNullableShortcutPair() =
|
||||
toContainExactlyElementsOfNullableShortcutFun.name to Companion::toContainExactlyElementsOfNullableShortcut;
|
||||
|
||||
private fun containsExactlyElementsOfNullableShortcut(
|
||||
private fun toContainExactlyElementsOfNullableShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> = expect containsExactlyElementsOf sequenceOf(a, *aX).asIterable()
|
||||
): Expect<Iterable<Double?>> = expect toContainExactlyElementsOf sequenceOf(a, *aX).asIterable()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,77 +4,77 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsInOrderOnlyEntriesExpectationsSpec : Spek({
|
||||
class IterableToContainInOrderOnlyEntriesExpectationsSpec : Spek({
|
||||
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToContainInOrderOnlyEntriesExpectationsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
getToContainPair(),
|
||||
getToContainNullablePair(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToContainInOrderOnlyEntriesExpectationsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair(),
|
||||
getToContainShortcutPair(),
|
||||
getToContainNullableShortcutPair(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderOnlyEntries" to Companion::containsInOrderOnly
|
||||
fun getToContainPair() =
|
||||
"$toContain $filler $inOrder $andOnly $inOrderOnlyEntries" to Companion::toContainInOrderOnly
|
||||
|
||||
private fun containsInOrderOnly(
|
||||
private fun toContainInOrderOnly(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inGiven order and only entry a
|
||||
else expect contains o inGiven order and only the entries(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inGiven order and only entry a
|
||||
else expect toContain o inGiven order and only the entries(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderOnlyEntries" to Companion::containsInOrderOnlyNullableEntriesPair
|
||||
fun getToContainNullablePair() =
|
||||
"$toContain $filler $inOrder $andOnly $inOrderOnlyEntries" to Companion::toContainInOrderOnlyNullableEntriesPair
|
||||
|
||||
private fun containsInOrderOnlyNullableEntriesPair(
|
||||
private fun toContainInOrderOnlyNullableEntriesPair(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inGiven order and only entry a
|
||||
else expect contains o inGiven order and only the entries(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inGiven order and only entry a
|
||||
else expect toContain o inGiven order and only the entries(a, *aX)
|
||||
|
||||
private val containsShortcutFun: KFunction2<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::containsExactly
|
||||
private val toContainShortcutFun: KFunction2<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::toContainExactly
|
||||
|
||||
fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInOrderOnlyEntriesShortcut
|
||||
fun getToContainShortcutPair() = toContainShortcutFun.name to Companion::toContainInOrderOnlyEntriesShortcut
|
||||
|
||||
private fun containsInOrderOnlyEntriesShortcut(
|
||||
private fun toContainInOrderOnlyEntriesShortcut(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect containsExactly { a() }
|
||||
else expect containsExactly entries(a, *aX)
|
||||
if (aX.isEmpty()) expect toContainExactly { a() }
|
||||
else expect toContainExactly entries(a, *aX)
|
||||
|
||||
private val containsNullableShortcutFun: KFunction2<Expect<Iterable<Double?>>, (Expect<Double>.() -> Unit)?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::containsExactly
|
||||
private val toContainNullableShortcutFun: KFunction2<Expect<Iterable<Double?>>, (Expect<Double>.() -> Unit)?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::toContainExactly
|
||||
|
||||
fun getContainsNullableShortcutPair() =
|
||||
containsNullableShortcutFun.name to Companion::containsInOrderOnlyNullableEntriesShortcut
|
||||
fun getToContainNullableShortcutPair() =
|
||||
toContainNullableShortcutFun.name to Companion::toContainInOrderOnlyNullableEntriesShortcut
|
||||
|
||||
private fun containsInOrderOnlyNullableEntriesShortcut(
|
||||
private fun toContainInOrderOnlyNullableEntriesShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) {
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
if (a == null) expect containsExactly a as Double?
|
||||
else expect containsExactly { a() }
|
||||
if (a == null) expect toContainExactly a as Double?
|
||||
else expect toContainExactly { a() }
|
||||
} else {
|
||||
expect containsExactly entries(a, *aX)
|
||||
expect toContainExactly entries(a, *aX)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,73 +4,73 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsInOrderOnlyValuesExpectationsSpec : Spek({
|
||||
class IterableToContainInOrderOnlyValuesExpectationsSpec : Spek({
|
||||
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToContainInOrderOnlyValuesExpectationsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
getToContainPair(),
|
||||
getToContainNullablePair(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableToContainInOrderOnlyValuesExpectationsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair(),
|
||||
getToContainShortcutPair(),
|
||||
getToContainNullableShortcutPair(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::containsInOrderOnlyValues
|
||||
fun getToContainPair() =
|
||||
"$toContain $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::toContainInOrderOnlyValues
|
||||
|
||||
private fun containsInOrderOnlyValues(
|
||||
private fun toContainInOrderOnlyValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inGiven order and only value a
|
||||
else expect contains o inGiven order and only the values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inGiven order and only value a
|
||||
else expect toContain o inGiven order and only the values(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::containsInOrderOnlyNullableValues
|
||||
fun getToContainNullablePair() =
|
||||
"$toContain $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::toContainInOrderOnlyNullableValues
|
||||
|
||||
private fun containsInOrderOnlyNullableValues(
|
||||
private fun toContainInOrderOnlyNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inGiven order and only value a
|
||||
else expect contains o inGiven order and only the values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inGiven order and only value a
|
||||
else expect toContain o inGiven order and only the values(a, *aX)
|
||||
|
||||
private val containsShortcutFun: KFunction2<Expect<Iterable<Double>>, Double, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::containsExactly
|
||||
private val toContainShortcutFun: KFunction2<Expect<Iterable<Double>>, Double, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::toContainExactly
|
||||
|
||||
fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInOrderOnlyValuesShortcut
|
||||
fun getToContainShortcutPair() = toContainShortcutFun.name to Companion::toContainInOrderOnlyValuesShortcut
|
||||
|
||||
private fun containsInOrderOnlyValuesShortcut(
|
||||
private fun toContainInOrderOnlyValuesShortcut(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect containsExactly a
|
||||
else expect containsExactly values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContainExactly a
|
||||
else expect toContainExactly values(a, *aX)
|
||||
|
||||
private val containsNullableShortcutFun: KFunction2<Expect<Iterable<Double?>>, Double?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::containsExactly
|
||||
private val toContainNullableShortcutFun: KFunction2<Expect<Iterable<Double?>>, Double?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::toContainExactly
|
||||
|
||||
fun getContainsNullableShortcutPair() =
|
||||
containsNullableShortcutFun.name to Companion::containsInOrderOnlyNullableValuesShortcut
|
||||
fun getToContainNullableShortcutPair() =
|
||||
toContainNullableShortcutFun.name to Companion::toContainInOrderOnlyNullableValuesShortcut
|
||||
|
||||
private fun containsInOrderOnlyNullableValuesShortcut(
|
||||
private fun toContainInOrderOnlyNullableValuesShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect containsExactly a
|
||||
else expect containsExactly values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContainExactly a
|
||||
else expect toContainExactly values(a, *aX)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsNotValuesExpectationsSpec : Spek({
|
||||
class IterableNotToContainValuesExpectationsSpec : Spek({
|
||||
|
||||
include(BuilderSpecToContain)
|
||||
include(ShortcutSpecToContain)
|
||||
@@ -12,46 +12,46 @@ class IterableContainsNotValuesExpectationsSpec : Spek({
|
||||
}) {
|
||||
|
||||
object BuilderSpecToContain : ch.tutteli.atrium.specs.integration.IterableNotToContainValuesExpectationsSpec(
|
||||
getContainsNotPair(),
|
||||
getContainsNotNullablePair(),
|
||||
getNotToContainPair(),
|
||||
getNotToContainNullablePair(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpecToContain : ch.tutteli.atrium.specs.integration.IterableNotToContainValuesExpectationsSpec(
|
||||
getContainsNotShortcutPair(),
|
||||
getContainsNotNullablePair(),
|
||||
getNotToContainShortcutPair(),
|
||||
getNotToContainNullablePair(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::containsNotFun
|
||||
private fun getNotToContainPair() = notToContain to Companion::notToContainFun
|
||||
|
||||
private fun containsNotFun(
|
||||
private fun notToContainFun(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect containsNot o value a
|
||||
else expect containsNot o the values(a, *aX)
|
||||
if (aX.isEmpty()) expect notToContain o value a
|
||||
else expect notToContain o the values(a, *aX)
|
||||
|
||||
private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun
|
||||
private fun getNotToContainNullablePair() = notToContain to Companion::notToContainNullableFun
|
||||
|
||||
private fun containsNotNullableFun(
|
||||
private fun notToContainNullableFun(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect containsNot o value a
|
||||
else expect containsNot o the values(a, *aX)
|
||||
if (aX.isEmpty()) expect notToContain o value a
|
||||
else expect notToContain o the values(a, *aX)
|
||||
|
||||
private val containsNotShortcutFun: KFunction2<Expect<Iterable<Double>>, Double, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::containsNot
|
||||
private val notToContainShortcutFun: KFunction2<Expect<Iterable<Double>>, Double, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::notToContain
|
||||
|
||||
private fun getContainsNotShortcutPair() = containsNotShortcutFun.name to Companion::containsNotShortcut
|
||||
private fun getNotToContainShortcutPair() = notToContainShortcutFun.name to Companion::notToContainShortcut
|
||||
|
||||
private fun containsNotShortcut(expect: Expect<Iterable<Double>>, a: Double, aX: Array<out Double>) =
|
||||
if (aX.isEmpty()) expect containsNot a
|
||||
else expect containsNot values(a, *aX)
|
||||
private fun notToContainShortcut(expect: Expect<Iterable<Double>>, a: Double, aX: Array<out Double>) =
|
||||
if (aX.isEmpty()) expect notToContain a
|
||||
else expect notToContain values(a, *aX)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import ch.tutteli.atrium.api.infix.en_GB.creating.Values
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.Order
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.utils.Group
|
||||
//TODO rename iterable.contains to iterable.toContain with 0.18.0
|
||||
import ch.tutteli.atrium.logic.creating.iterable.contains.IterableLikeContains
|
||||
import ch.tutteli.atrium.logic.creating.iterable.contains.searchbehaviours.*
|
||||
import ch.tutteli.atrium.logic.creating.iterable.contains.steps.AtLeastCheckerStep
|
||||
@@ -62,12 +63,12 @@ abstract class IterableContainsSpecBase {
|
||||
//@formatter:on
|
||||
|
||||
protected val filler = o::class.simpleName
|
||||
private val containsProp: KFunction2<Expect<Iterable<Int>>, o, IterableLikeContains.EntryPointStep<Int, Iterable<Int>, NoOpSearchBehaviour>> =
|
||||
Expect<Iterable<Int>>::contains
|
||||
protected val contains = containsProp.name
|
||||
private val containsNotProp: KFunction2<Expect<Iterable<Int>>, o, NotCheckerStep<Int, Iterable<Int>, NotSearchBehaviour>> =
|
||||
Expect<Iterable<Int>>::containsNot
|
||||
protected val containsNot = "${containsNotProp.name} $Values"
|
||||
private val toContainProp: KFunction2<Expect<Iterable<Int>>, o, IterableLikeContains.EntryPointStep<Int, Iterable<Int>, NoOpSearchBehaviour>> =
|
||||
Expect<Iterable<Int>>::toContain
|
||||
protected val toContain = toContainProp.name
|
||||
private val notToContainProp: KFunction2<Expect<Iterable<Int>>, o, NotCheckerStep<Int, Iterable<Int>, NotSearchBehaviour>> =
|
||||
Expect<Iterable<Int>>::notToContain
|
||||
protected val notToContain = "${notToContainProp.name} $Values"
|
||||
|
||||
@Suppress("unused")
|
||||
private fun ambiguityTest() {
|
||||
@@ -77,236 +78,236 @@ abstract class IterableContainsSpecBase {
|
||||
val star: Expect<Collection<*>> = notImplemented()
|
||||
val any: Expect<Collection<Any>> = notImplemented()
|
||||
|
||||
list contains 1
|
||||
list contains 1f
|
||||
list contains values(1, 2f)
|
||||
list contains {}
|
||||
list contains entries({}, {})
|
||||
list containsNot 1
|
||||
list containsNot 1f
|
||||
list containsNot values(1, 2f)
|
||||
list containsNot o entry {}
|
||||
list containsNot o the entries({}, {})
|
||||
list toContain 1
|
||||
list toContain 1f
|
||||
list toContain values(1, 2f)
|
||||
list toContain {}
|
||||
list toContain entries({}, {})
|
||||
list notToContain 1
|
||||
list notToContain 1f
|
||||
list notToContain values(1, 2f)
|
||||
list notToContain o entry {}
|
||||
list notToContain o the entries({}, {})
|
||||
|
||||
subList contains 1
|
||||
subList contains 1f; subList contains values(1, 2f)
|
||||
subList contains {}
|
||||
subList contains entries({}, {})
|
||||
subList containsNot 1
|
||||
subList containsNot 1f
|
||||
subList containsNot values(1, 2f)
|
||||
subList containsNot o entry {}
|
||||
subList containsNot o the entries({}, {})
|
||||
subList toContain 1
|
||||
subList toContain 1f; subList toContain values(1, 2f)
|
||||
subList toContain {}
|
||||
subList toContain entries({}, {})
|
||||
subList notToContain 1
|
||||
subList notToContain 1f
|
||||
subList notToContain values(1, 2f)
|
||||
subList notToContain o entry {}
|
||||
subList notToContain o the entries({}, {})
|
||||
|
||||
nullableList contains 1
|
||||
nullableList contains 1f
|
||||
nullableList contains values(1, 2f)
|
||||
nullableList contains {}
|
||||
nullableList contains entries({}, {})
|
||||
nullableList containsNot 1
|
||||
nullableList containsNot 1f
|
||||
nullableList containsNot values(1, 2f)
|
||||
nullableList containsNot o entry {}
|
||||
nullableList containsNot o the entries({}, {})
|
||||
nullableList toContain 1
|
||||
nullableList toContain 1f
|
||||
nullableList toContain values(1, 2f)
|
||||
nullableList toContain {}
|
||||
nullableList toContain entries({}, {})
|
||||
nullableList notToContain 1
|
||||
nullableList notToContain 1f
|
||||
nullableList notToContain values(1, 2f)
|
||||
nullableList notToContain o entry {}
|
||||
nullableList notToContain o the entries({}, {})
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
nullableList contains null as Number?
|
||||
nullableList contains entries(null, {})
|
||||
nullableList contains entries({}, null)
|
||||
nullableList contains entries(null, null)
|
||||
nullableList toContain null as Number?
|
||||
nullableList toContain entries(null, {})
|
||||
nullableList toContain entries({}, null)
|
||||
nullableList toContain entries(null, null)
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
nullableList containsNot null as Number?
|
||||
nullableList containsNot o the entries(null, {})
|
||||
nullableList containsNot o the entries({}, null)
|
||||
nullableList containsNot o the entries(null, null)
|
||||
nullableList notToContain null as Number?
|
||||
nullableList notToContain o the entries(null, {})
|
||||
nullableList notToContain o the entries({}, null)
|
||||
nullableList notToContain o the entries(null, null)
|
||||
|
||||
star contains 1
|
||||
star contains 1f
|
||||
star contains values(1, 2f)
|
||||
star contains {}
|
||||
star contains entries({}, {})
|
||||
star containsNot 1
|
||||
star containsNot 1f
|
||||
star containsNot values(1, 2f)
|
||||
star containsNot o entry {}
|
||||
star containsNot o the entries({}, {})
|
||||
star toContain 1
|
||||
star toContain 1f
|
||||
star toContain values(1, 2f)
|
||||
star toContain {}
|
||||
star toContain entries({}, {})
|
||||
star notToContain 1
|
||||
star notToContain 1f
|
||||
star notToContain values(1, 2f)
|
||||
star notToContain o entry {}
|
||||
star notToContain o the entries({}, {})
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
star contains (null as Number?)
|
||||
star contains entries(null, {})
|
||||
star contains entries({}, null)
|
||||
star contains entries(null, null)
|
||||
star toContain (null as Number?)
|
||||
star toContain entries(null, {})
|
||||
star toContain entries({}, null)
|
||||
star toContain entries(null, null)
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
star containsNot (null as Number?)
|
||||
star containsNot o the entries(null, {})
|
||||
star containsNot o the entries({}, null)
|
||||
star containsNot o the entries(null, null)
|
||||
star notToContain (null as Number?)
|
||||
star notToContain o the entries(null, {})
|
||||
star notToContain o the entries({}, null)
|
||||
star notToContain o the entries(null, null)
|
||||
|
||||
list containsExactly 1
|
||||
list containsExactly values(1, 2f)
|
||||
list containsExactly {}
|
||||
list containsExactly entries({}, {})
|
||||
list toContainExactly 1
|
||||
list toContainExactly values(1, 2f)
|
||||
list toContainExactly {}
|
||||
list toContainExactly entries({}, {})
|
||||
|
||||
subList containsExactly 1
|
||||
subList containsExactly values(1, 2f)
|
||||
subList containsExactly {}
|
||||
subList containsExactly entries({}, {})
|
||||
subList toContainExactly 1
|
||||
subList toContainExactly values(1, 2f)
|
||||
subList toContainExactly {}
|
||||
subList toContainExactly entries({}, {})
|
||||
|
||||
nullableList containsExactly 1
|
||||
nullableList containsExactly values(1, 2f)
|
||||
nullableList containsExactly {}
|
||||
nullableList containsExactly entries({}, {})
|
||||
nullableList toContainExactly 1
|
||||
nullableList toContainExactly values(1, 2f)
|
||||
nullableList toContainExactly {}
|
||||
nullableList toContainExactly entries({}, {})
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
nullableList containsExactly (null as (Expect<Number>.() -> Unit)?)
|
||||
nullableList containsExactly entries({}, null)
|
||||
nullableList containsExactly entries(null, {})
|
||||
nullableList containsExactly entries(null, null)
|
||||
nullableList toContainExactly (null as (Expect<Number>.() -> Unit)?)
|
||||
nullableList toContainExactly entries({}, null)
|
||||
nullableList toContainExactly entries(null, {})
|
||||
nullableList toContainExactly entries(null, null)
|
||||
|
||||
star containsExactly 1
|
||||
star containsExactly values(1, 2f)
|
||||
star containsExactly {}
|
||||
star containsExactly entries({}, {})
|
||||
star toContainExactly 1
|
||||
star toContainExactly values(1, 2f)
|
||||
star toContainExactly {}
|
||||
star toContainExactly entries({}, {})
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
star containsExactly (null as (Expect<Number>.() -> Unit)?)
|
||||
star containsExactly entries({}, null)
|
||||
star containsExactly entries(null, {})
|
||||
star containsExactly entries(null, null)
|
||||
star toContainExactly (null as (Expect<Number>.() -> Unit)?)
|
||||
star toContainExactly entries({}, null)
|
||||
star toContainExactly entries(null, {})
|
||||
star toContainExactly entries(null, null)
|
||||
|
||||
list contains o inAny order atLeast 1 value 1
|
||||
list contains o inAny order atLeast 1 the values(2, 1)
|
||||
list contains o inAny order atLeast 1 entry {}
|
||||
list contains o inAny order atLeast 1 the entries({}, {})
|
||||
list contains o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
subList contains o inAny order atLeast 1 value 1
|
||||
subList contains o inAny order atLeast 1 the values(2, 1)
|
||||
subList contains o inAny order atLeast 1 entry {}
|
||||
subList contains o inAny order atLeast 1 the entries({}, {})
|
||||
subList contains o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
nullableList contains o inAny order atLeast 1 value 1
|
||||
nullableList contains o inAny order atLeast 1 the values(2, 1)
|
||||
nullableList contains o inAny order atLeast 1 entry {}
|
||||
nullableList contains o inAny order atLeast 1 the entries({}, {})
|
||||
nullableList contains o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
nullableList contains o inAny order atLeast 1 value null
|
||||
nullableList contains o inAny order atLeast 1 the values(null, 1)
|
||||
nullableList contains o inAny order atLeast 1 the values(2, null)
|
||||
nullableList contains o inAny order atLeast 1 the values(null, null)
|
||||
nullableList contains o inAny order atLeast 1 entry null
|
||||
nullableList contains o inAny order atLeast 1 the entries(null, {})
|
||||
nullableList contains o inAny order atLeast 1 the entries({}, null)
|
||||
nullableList contains o inAny order atLeast 1 the entries(null, null)
|
||||
star contains o inAny order atLeast 1 value 1
|
||||
star contains o inAny order atLeast 1 the values(2, 1)
|
||||
star contains o inAny order atLeast 1 entry {}
|
||||
star contains o inAny order atLeast 1 the entries({}, {})
|
||||
star contains o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
star contains o inAny order atLeast 1 value null
|
||||
star contains o inAny order atLeast 1 the values(null, 1)
|
||||
star contains o inAny order atLeast 1 the values(2, null)
|
||||
star contains o inAny order atLeast 1 the values(null, null)
|
||||
star contains o inAny order atLeast 1 entry null
|
||||
star contains o inAny order atLeast 1 the entries(null, {})
|
||||
star contains o inAny order atLeast 1 the entries({}, null)
|
||||
star contains o inAny order atLeast 1 the entries(null, null)
|
||||
list toContain o inAny order atLeast 1 value 1
|
||||
list toContain o inAny order atLeast 1 the values(2, 1)
|
||||
list toContain o inAny order atLeast 1 entry {}
|
||||
list toContain o inAny order atLeast 1 the entries({}, {})
|
||||
list toContain o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
subList toContain o inAny order atLeast 1 value 1
|
||||
subList toContain o inAny order atLeast 1 the values(2, 1)
|
||||
subList toContain o inAny order atLeast 1 entry {}
|
||||
subList toContain o inAny order atLeast 1 the entries({}, {})
|
||||
subList toContain o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
nullableList toContain o inAny order atLeast 1 value 1
|
||||
nullableList toContain o inAny order atLeast 1 the values(2, 1)
|
||||
nullableList toContain o inAny order atLeast 1 entry {}
|
||||
nullableList toContain o inAny order atLeast 1 the entries({}, {})
|
||||
nullableList toContain o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
nullableList toContain o inAny order atLeast 1 value null
|
||||
nullableList toContain o inAny order atLeast 1 the values(null, 1)
|
||||
nullableList toContain o inAny order atLeast 1 the values(2, null)
|
||||
nullableList toContain o inAny order atLeast 1 the values(null, null)
|
||||
nullableList toContain o inAny order atLeast 1 entry null
|
||||
nullableList toContain o inAny order atLeast 1 the entries(null, {})
|
||||
nullableList toContain o inAny order atLeast 1 the entries({}, null)
|
||||
nullableList toContain o inAny order atLeast 1 the entries(null, null)
|
||||
star toContain o inAny order atLeast 1 value 1
|
||||
star toContain o inAny order atLeast 1 the values(2, 1)
|
||||
star toContain o inAny order atLeast 1 entry {}
|
||||
star toContain o inAny order atLeast 1 the entries({}, {})
|
||||
star toContain o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
star toContain o inAny order atLeast 1 value null
|
||||
star toContain o inAny order atLeast 1 the values(null, 1)
|
||||
star toContain o inAny order atLeast 1 the values(2, null)
|
||||
star toContain o inAny order atLeast 1 the values(null, null)
|
||||
star toContain o inAny order atLeast 1 entry null
|
||||
star toContain o inAny order atLeast 1 the entries(null, {})
|
||||
star toContain o inAny order atLeast 1 the entries({}, null)
|
||||
star toContain o inAny order atLeast 1 the entries(null, null)
|
||||
|
||||
list contains o inAny order but only value 1
|
||||
list contains o inAny order but only the values(2, 1)
|
||||
list contains o inAny order but only entry {}
|
||||
list contains o inAny order but only the entries({}, {})
|
||||
list contains o inAny order but only elementsOf listOf(1, 2)
|
||||
subList contains o inAny order but only value 1
|
||||
subList contains o inAny order but only the values(2, 1)
|
||||
subList contains o inAny order but only entry {}
|
||||
subList contains o inAny order but only the entries({}, {})
|
||||
subList contains o inAny order but only elementsOf listOf(1, 2)
|
||||
nullableList contains o inAny order but only value 1
|
||||
nullableList contains o inAny order but only the values(2, 1)
|
||||
nullableList contains o inAny order but only entry {}
|
||||
nullableList contains o inAny order but only the entries({}, {})
|
||||
nullableList contains o inAny order but only elementsOf listOf(1, 2)
|
||||
nullableList contains o inAny order but only value null
|
||||
nullableList contains o inAny order but only the values(null, 1)
|
||||
nullableList contains o inAny order but only the values(2, null)
|
||||
nullableList contains o inAny order but only the values(null, null)
|
||||
nullableList contains o inAny order but only entry null
|
||||
nullableList contains o inAny order but only the entries(null, {})
|
||||
nullableList contains o inAny order but only the entries({}, null)
|
||||
nullableList contains o inAny order but only the entries(null, null)
|
||||
star contains o inAny order but only value 1
|
||||
star contains o inAny order but only the values(2, 1)
|
||||
star contains o inAny order but only entry {}
|
||||
star contains o inAny order but only the entries({}, {})
|
||||
star contains o inAny order but only elementsOf listOf(1, 2)
|
||||
star contains o inAny order but only value null
|
||||
star contains o inAny order but only the values(null, 1)
|
||||
star contains o inAny order but only the values(2, null)
|
||||
star contains o inAny order but only the values(null, null)
|
||||
star contains o inAny order but only entry null
|
||||
star contains o inAny order but only the entries(null, {})
|
||||
star contains o inAny order but only the entries({}, null)
|
||||
star contains o inAny order but only the entries(null, null)
|
||||
list toContain o inAny order but only value 1
|
||||
list toContain o inAny order but only the values(2, 1)
|
||||
list toContain o inAny order but only entry {}
|
||||
list toContain o inAny order but only the entries({}, {})
|
||||
list toContain o inAny order but only elementsOf listOf(1, 2)
|
||||
subList toContain o inAny order but only value 1
|
||||
subList toContain o inAny order but only the values(2, 1)
|
||||
subList toContain o inAny order but only entry {}
|
||||
subList toContain o inAny order but only the entries({}, {})
|
||||
subList toContain o inAny order but only elementsOf listOf(1, 2)
|
||||
nullableList toContain o inAny order but only value 1
|
||||
nullableList toContain o inAny order but only the values(2, 1)
|
||||
nullableList toContain o inAny order but only entry {}
|
||||
nullableList toContain o inAny order but only the entries({}, {})
|
||||
nullableList toContain o inAny order but only elementsOf listOf(1, 2)
|
||||
nullableList toContain o inAny order but only value null
|
||||
nullableList toContain o inAny order but only the values(null, 1)
|
||||
nullableList toContain o inAny order but only the values(2, null)
|
||||
nullableList toContain o inAny order but only the values(null, null)
|
||||
nullableList toContain o inAny order but only entry null
|
||||
nullableList toContain o inAny order but only the entries(null, {})
|
||||
nullableList toContain o inAny order but only the entries({}, null)
|
||||
nullableList toContain o inAny order but only the entries(null, null)
|
||||
star toContain o inAny order but only value 1
|
||||
star toContain o inAny order but only the values(2, 1)
|
||||
star toContain o inAny order but only entry {}
|
||||
star toContain o inAny order but only the entries({}, {})
|
||||
star toContain o inAny order but only elementsOf listOf(1, 2)
|
||||
star toContain o inAny order but only value null
|
||||
star toContain o inAny order but only the values(null, 1)
|
||||
star toContain o inAny order but only the values(2, null)
|
||||
star toContain o inAny order but only the values(null, null)
|
||||
star toContain o inAny order but only entry null
|
||||
star toContain o inAny order but only the entries(null, {})
|
||||
star toContain o inAny order but only the entries({}, null)
|
||||
star toContain o inAny order but only the entries(null, null)
|
||||
|
||||
list contains o inGiven order and only value 1
|
||||
list contains o inGiven order and only the values(2, 1)
|
||||
list contains o inGiven order and only entry {}
|
||||
list contains o inGiven order and only the entries({}, {})
|
||||
list contains o inGiven order and only elementsOf listOf(1, 2)
|
||||
subList contains o inGiven order and only value 1
|
||||
subList contains o inGiven order and only the values(2, 1)
|
||||
subList contains o inGiven order and only entry {}
|
||||
subList contains o inGiven order and only the entries({}, {})
|
||||
subList contains o inGiven order and only elementsOf listOf(1, 2)
|
||||
nullableList contains o inGiven order and only value 1
|
||||
nullableList contains o inGiven order and only the values(2, 1)
|
||||
nullableList contains o inGiven order and only entry {}
|
||||
nullableList contains o inGiven order and only the entries({}, {})
|
||||
nullableList contains o inGiven order and only elementsOf listOf(1, 2)
|
||||
nullableList contains o inGiven order and only value null
|
||||
nullableList contains o inGiven order and only the values(null, 1)
|
||||
nullableList contains o inGiven order and only the values(2, null)
|
||||
nullableList contains o inGiven order and only the values(null, null)
|
||||
nullableList contains o inGiven order and only entry null
|
||||
nullableList contains o inGiven order and only the entries(null, {})
|
||||
nullableList contains o inGiven order and only the entries({}, null)
|
||||
nullableList contains o inGiven order and only the entries(null, null)
|
||||
star contains o inGiven order and only value 1
|
||||
star contains o inGiven order and only the values(2, 1)
|
||||
star contains o inGiven order and only entry {}
|
||||
star contains o inGiven order and only the entries({}, {})
|
||||
star contains o inGiven order and only elementsOf listOf(1, 2)
|
||||
star contains o inGiven order and only value null
|
||||
star contains o inGiven order and only the values(null, 1)
|
||||
star contains o inGiven order and only the values(2, null)
|
||||
star contains o inGiven order and only the values(null, null)
|
||||
star contains o inGiven order and only entry null
|
||||
star contains o inGiven order and only the entries(null, {})
|
||||
star contains o inGiven order and only the entries({}, null)
|
||||
star contains o inGiven order and only the entries(null, null)
|
||||
list toContain o inGiven order and only value 1
|
||||
list toContain o inGiven order and only the values(2, 1)
|
||||
list toContain o inGiven order and only entry {}
|
||||
list toContain o inGiven order and only the entries({}, {})
|
||||
list toContain o inGiven order and only elementsOf listOf(1, 2)
|
||||
subList toContain o inGiven order and only value 1
|
||||
subList toContain o inGiven order and only the values(2, 1)
|
||||
subList toContain o inGiven order and only entry {}
|
||||
subList toContain o inGiven order and only the entries({}, {})
|
||||
subList toContain o inGiven order and only elementsOf listOf(1, 2)
|
||||
nullableList toContain o inGiven order and only value 1
|
||||
nullableList toContain o inGiven order and only the values(2, 1)
|
||||
nullableList toContain o inGiven order and only entry {}
|
||||
nullableList toContain o inGiven order and only the entries({}, {})
|
||||
nullableList toContain o inGiven order and only elementsOf listOf(1, 2)
|
||||
nullableList toContain o inGiven order and only value null
|
||||
nullableList toContain o inGiven order and only the values(null, 1)
|
||||
nullableList toContain o inGiven order and only the values(2, null)
|
||||
nullableList toContain o inGiven order and only the values(null, null)
|
||||
nullableList toContain o inGiven order and only entry null
|
||||
nullableList toContain o inGiven order and only the entries(null, {})
|
||||
nullableList toContain o inGiven order and only the entries({}, null)
|
||||
nullableList toContain o inGiven order and only the entries(null, null)
|
||||
star toContain o inGiven order and only value 1
|
||||
star toContain o inGiven order and only the values(2, 1)
|
||||
star toContain o inGiven order and only entry {}
|
||||
star toContain o inGiven order and only the entries({}, {})
|
||||
star toContain o inGiven order and only elementsOf listOf(1, 2)
|
||||
star toContain o inGiven order and only value null
|
||||
star toContain o inGiven order and only the values(null, 1)
|
||||
star toContain o inGiven order and only the values(2, null)
|
||||
star toContain o inGiven order and only the values(null, null)
|
||||
star toContain o inGiven order and only entry null
|
||||
star toContain o inGiven order and only the entries(null, {})
|
||||
star toContain o inGiven order and only the entries({}, null)
|
||||
star toContain o inGiven order and only the entries(null, null)
|
||||
|
||||
list contains o inGiven order and only grouped entries within group inAny order(
|
||||
list toContain o inGiven order and only grouped entries within group inAny order(
|
||||
value(1),
|
||||
values(1f),
|
||||
//TODO check if this is resolved correctly with kotlin 1.4 otherwise report an issue
|
||||
values<Number>(1f, 1)
|
||||
)
|
||||
subList contains o inGiven order and only grouped entries within group inAny order(
|
||||
subList toContain o inGiven order and only grouped entries within group inAny order(
|
||||
value(1),
|
||||
values(1f),
|
||||
values<Number>(1f, 1)
|
||||
)
|
||||
nullableList contains o inGiven order and only grouped entries within group inAny order(
|
||||
nullableList toContain o inGiven order and only grouped entries within group inAny order(
|
||||
value(null),
|
||||
values(null),
|
||||
values(null, 2),
|
||||
values(1, null),
|
||||
values(null, null)
|
||||
)
|
||||
star contains o inGiven order and only grouped entries within group inAny order(
|
||||
star toContain o inGiven order and only grouped entries within group inAny order(
|
||||
value(null),
|
||||
values(null),
|
||||
values(null, 2),
|
||||
values(1, null),
|
||||
values(null, null)
|
||||
)
|
||||
any contains o inGiven order and only grouped entries within group inAny order(
|
||||
any toContain o inGiven order and only grouped entries within group inAny order(
|
||||
value(1),
|
||||
values(2),
|
||||
values(1f, 2),
|
||||
@@ -314,19 +315,19 @@ abstract class IterableContainsSpecBase {
|
||||
values("je", 'a')
|
||||
)
|
||||
|
||||
list contains o inGiven order and only grouped entries within group inAny order(
|
||||
list toContain o inGiven order and only grouped entries within group inAny order(
|
||||
//TODO check if this is resolved correctly with kotlin 1.4 otherwise report an issue
|
||||
entry<Number> {},
|
||||
entries({}),
|
||||
entries({}, {})
|
||||
)
|
||||
subList contains o inGiven order and only grouped entries within group inAny order(
|
||||
subList toContain o inGiven order and only grouped entries within group inAny order(
|
||||
//TODO check if this is resolved correctly with kotlin 1.4 otherwise report an issue
|
||||
entry<Number> {},
|
||||
entries({}),
|
||||
entries({}, {})
|
||||
)
|
||||
nullableList contains o inGiven order and only grouped entries within group inAny order(
|
||||
nullableList toContain o inGiven order and only grouped entries within group inAny order(
|
||||
//TODO check if this is resolved correctly with kotlin 1.4 otherwise report an issue
|
||||
entry<Number>(null),
|
||||
entries(null),
|
||||
@@ -334,7 +335,7 @@ abstract class IterableContainsSpecBase {
|
||||
entries({}, null),
|
||||
entries(null, null)
|
||||
)
|
||||
star contains o inGiven order and only grouped entries within group inAny order(
|
||||
star toContain o inGiven order and only grouped entries within group inAny order(
|
||||
//TODO this should fail IMO
|
||||
entry<Number>(null),
|
||||
entries(null),
|
||||
@@ -342,7 +343,7 @@ abstract class IterableContainsSpecBase {
|
||||
entries({}, null),
|
||||
entries(null, null)
|
||||
)
|
||||
any contains o inGiven order and only grouped entries within group inAny order(
|
||||
any toContain o inGiven order and only grouped entries within group inAny order(
|
||||
//TODO check if this is resolved correctly with kotlin 1.4 otherwise report an issue
|
||||
entry<Any>(null),
|
||||
entries(null),
|
||||
|
||||
@@ -11,7 +11,7 @@ class IterableExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableExp
|
||||
fun1<Iterable<Int>, Expect<Int>.() -> Unit>(Expect<Iterable<Int>>::min),
|
||||
maxFeaturePair(),
|
||||
fun1<Iterable<Int>, Expect<Int>.() -> Unit>(Expect<Iterable<Int>>::max),
|
||||
getContainsNoDuplicatesPair()
|
||||
getToContainNoDuplicatesPair()
|
||||
) {
|
||||
companion object {
|
||||
private val has: KFunction2<Expect<Iterable<Int>>, next, Expect<Iterable<Int>>> = Expect<Iterable<Int>>::has
|
||||
@@ -30,13 +30,13 @@ class IterableExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableExp
|
||||
private fun maxFeaturePair() = feature1<Iterable<Int>, o, Int>(Expect<Iterable<Int>>::min).name to ::maxFeature
|
||||
private fun maxFeature(expect: Expect<Iterable<Int>>) = expect max o
|
||||
|
||||
private val containsDuplicates: KFunction2<Expect<Iterable<Int>>, noDuplicates, Expect<Iterable<Int>>> =
|
||||
Expect<Iterable<Int>>::contains
|
||||
private val notToContainDuplicates: KFunction2<Expect<Iterable<Int>>, duplicates, Expect<Iterable<Int>>> =
|
||||
Expect<Iterable<Int>>::notToContain
|
||||
|
||||
private fun getContainsNoDuplicatesPair() =
|
||||
"${containsDuplicates.name} ${noDuplicates::class.simpleName}" to Companion::containsNoDuplicates
|
||||
private fun getToContainNoDuplicatesPair() =
|
||||
"${notToContainDuplicates.name} ${duplicates::class.simpleName}" to Companion::toContainNoDuplicates
|
||||
|
||||
private fun containsNoDuplicates(expect: Expect<Iterable<Int>>) = expect contains noDuplicates
|
||||
private fun toContainNoDuplicates(expect: Expect<Iterable<Int>>) = expect notToContain duplicates
|
||||
|
||||
}
|
||||
|
||||
@@ -48,15 +48,15 @@ class IterableExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableExp
|
||||
|
||||
a1 = a1 has next
|
||||
a1 = a1 hasNot next
|
||||
a1 = a1 contains noDuplicates
|
||||
a1 = a1 toContain noDuplicates
|
||||
|
||||
a1b = a1b has next
|
||||
a1b = a1b hasNot next
|
||||
a1b = a1b contains noDuplicates
|
||||
a1b = a1b toContain noDuplicates
|
||||
|
||||
star = star has next
|
||||
star = star hasNot next
|
||||
star = star contains noDuplicates
|
||||
star = star toContain noDuplicates
|
||||
|
||||
//nullable not supported by min/max or rather T : Comparable<T> does not exist for T? (one cannot implement an interface for the nullable type)
|
||||
//same for Iterable<*>
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
|
||||
class IterableNoneExpectationsSpec : Spek({
|
||||
|
||||
include(PredicateSpec)
|
||||
include(BuilderSpec)
|
||||
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableNoneExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::none),
|
||||
fun1(Expect<Iterable<Double?>>::none).withNullableSuffix(),
|
||||
"[Atrium][Predicate] "
|
||||
)
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableNoneExpectationsSpec(
|
||||
getContainsNotPair(),
|
||||
getContainsNotNullablePair().withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::containsNotFun
|
||||
|
||||
private fun containsNotFun(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect containsNot o entry a
|
||||
|
||||
private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun
|
||||
|
||||
private fun containsNotNullableFun(expect: Expect<Iterable<Double?>>, a: (Expect<Double>.() -> Unit)?) =
|
||||
expect containsNot o entry a
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<List<Double>> = notImplemented()
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1.none {}
|
||||
a1 = a1 containsNot o entry {}
|
||||
|
||||
a1b = a1b none {}
|
||||
a1b = a1b none null
|
||||
a1b = a1b containsNot o entry {}
|
||||
a1b = a1b containsNot o entry null
|
||||
|
||||
star = star.none {}
|
||||
star = star containsNot o entry {}
|
||||
}
|
||||
}
|
||||
@@ -5,31 +5,31 @@ import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
|
||||
class IterableNotToContainEntriesExpectationsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableNotToContainEntriesExpectationsSpec(
|
||||
getContainsNotPair(),
|
||||
getContainsNotNullablePair().withNullableSuffix(),
|
||||
getNotToContainPair(),
|
||||
getNotToContainNullablePair().withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
) {
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::containsNotFun
|
||||
private fun getNotToContainPair() = notToContain to Companion::notToContainFun
|
||||
|
||||
private fun containsNotFun(
|
||||
private fun notToContainFun(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect containsNot o entry a
|
||||
else expect containsNot o the entries(a, *aX)
|
||||
if (aX.isEmpty()) expect notToContain o entry a
|
||||
else expect notToContain o the entries(a, *aX)
|
||||
|
||||
private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun
|
||||
private fun getNotToContainNullablePair() = notToContain to Companion::notToContainNullableFun
|
||||
|
||||
private fun containsNotNullableFun(
|
||||
private fun notToContainNullableFun(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect containsNot o entry a
|
||||
else expect containsNot o the entries(a, *aX)
|
||||
if (aX.isEmpty()) expect notToContain o entry a
|
||||
else expect notToContain o the entries(a, *aX)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class IterableToContainInAnyOrderAtLeastValuesExpectationsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderAtLeastValuesExpectationsSpec(
|
||||
getAtLeastTriple(),
|
||||
getAtLeastButAtMostTriple(),
|
||||
getContainsNotPair(),
|
||||
getNotToContainPair(),
|
||||
getExactlyPair(),
|
||||
Companion::getErrorMsgAtLeastButAtMost
|
||||
) {
|
||||
@@ -14,34 +14,34 @@ class IterableToContainInAnyOrderAtLeastValuesExpectationsSpec :
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
internal fun getAtLeastTriple() =
|
||||
{ what: String, times: String -> "$contains $what in any order $atLeast $times" } to
|
||||
("$contains $filler $inAnyOrder $atLeast" to Companion::containsAtLeast)
|
||||
{ what: String, times: String -> "$toContain $what in any order $atLeast $times" } to
|
||||
("$toContain $filler $inAnyOrder $atLeast" to Companion::toContainAtLeast)
|
||||
|
||||
private fun containsAtLeast(
|
||||
private fun toContainAtLeast(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
atLeast: Int,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order atLeast atLeast value a
|
||||
else expect contains o inAny order atLeast atLeast the values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inAny order atLeast atLeast value a
|
||||
else expect toContain o inAny order atLeast atLeast the values(a, *aX)
|
||||
|
||||
|
||||
private fun getAtLeastButAtMostTriple() =
|
||||
{ what: String, timesAtLeast: String, timesAtMost: String -> "$contains $what $atLeast $timesAtLeast $butAtMost $timesAtMost" } to
|
||||
("$contains $filler $atLeast $butAtMost" to Companion::containsAtLeastButAtMost)
|
||||
{ what: String, timesAtLeast: String, timesAtMost: String -> "$toContain $what $atLeast $timesAtLeast $butAtMost $timesAtMost" } to
|
||||
("$toContain $filler $atLeast $butAtMost" to Companion::toContainAtLeastButAtMost)
|
||||
|
||||
private fun containsAtLeastButAtMost(
|
||||
private fun toContainAtLeastButAtMost(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
atLeast: Int,
|
||||
butAtMost: Int,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
) = expect contains o inAny order atLeast atLeast butAtMost butAtMost the values(a, *aX)
|
||||
) = expect toContain o inAny order atLeast atLeast butAtMost butAtMost the values(a, *aX)
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot
|
||||
private fun getNotToContainPair() = notToContain to Companion::getErrorMsgNotToContain
|
||||
|
||||
private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$atLeast $times`"
|
||||
private fun getErrorMsgNotToContain(times: Int) = "use `$notToContain` instead of `$atLeast $times`"
|
||||
|
||||
private fun getExactlyPair() = exactly to Companion::getErrorMsgExactly
|
||||
|
||||
|
||||
@@ -5,24 +5,24 @@ import ch.tutteli.atrium.creating.Expect
|
||||
class IterableToContainInAnyOrderAtMostValuesExpectationsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderAtMostValuesExpectationsSpec(
|
||||
getAtMostTriple(),
|
||||
getContainsNotPair(),
|
||||
getNotToContainPair(),
|
||||
getExactlyPair()
|
||||
) {
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getAtMostTriple() =
|
||||
{ what: String, times: String -> "$contains $what $atMost $times" } to
|
||||
("$contains $filler $inAnyOrder $atMost" to Companion::containsAtMost)
|
||||
{ what: String, times: String -> "$toContain $what $atMost $times" } to
|
||||
("$toContain $filler $inAnyOrder $atMost" to Companion::toContainAtMost)
|
||||
|
||||
private fun containsAtMost(expect: Expect<Iterable<Double>>, atMost: Int, a: Double, aX: Array<out Double>) =
|
||||
if(aX.isEmpty()) expect contains o inAny order atMost atMost value a
|
||||
else expect contains o inAny order atMost atMost the values(a, *aX)
|
||||
private fun toContainAtMost(expect: Expect<Iterable<Double>>, atMost: Int, a: Double, aX: Array<out Double>) =
|
||||
if(aX.isEmpty()) expect toContain o inAny order atMost atMost value a
|
||||
else expect toContain o inAny order atMost atMost the values(a, *aX)
|
||||
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot
|
||||
private fun getNotToContainPair() = notToContain to Companion::getErrorMsgNotToContain
|
||||
|
||||
private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$atMost $times`"
|
||||
private fun getErrorMsgNotToContain(times: Int) = "use `$notToContain` instead of `$atMost $times`"
|
||||
|
||||
private fun getExactlyPair() = exactly to Companion::getErrorMsgExactly
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@ import ch.tutteli.atrium.creating.Expect
|
||||
class IterableToContainInAnyOrderExactlyValuesExpectationsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderExactlyValuesExpectationsSpec(
|
||||
getExactlyTriple(),
|
||||
getContainsNotPair()
|
||||
getNotToContainPair()
|
||||
) {
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getExactlyTriple() =
|
||||
{ what: String, times: String -> "$contains $what $exactly $times" } to
|
||||
("$contains $filler $inAnyOrder $exactly" to Companion::containsExactly)
|
||||
{ what: String, times: String -> "$toContain $what $exactly $times" } to
|
||||
("$toContain $filler $inAnyOrder $exactly" to Companion::containsExactly)
|
||||
|
||||
private fun containsExactly(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
@@ -23,9 +23,9 @@ class IterableToContainInAnyOrderExactlyValuesExpectationsSpec :
|
||||
if (aX.isEmpty()) expect contains o inAny order exactly exactly value a
|
||||
else expect contains o inAny order exactly exactly the values(a, *aX)
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot
|
||||
private fun getNotToContainPair() = notToContain to Companion::getErrorMsgNotToContain
|
||||
|
||||
private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$exactly $times`"
|
||||
private fun getErrorMsgNotToContain(times: Int) = "use `$notToContain` instead of `$exactly $times`"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,27 +5,27 @@ import ch.tutteli.atrium.creating.Expect
|
||||
class IterableToContainInAnyOrderNotOrAtMostValuesExpectationsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableToContainInAnyOrderNotOrAtMostValuesExpectationsSpec(
|
||||
getNotOrAtMostTriple(),
|
||||
getContainsNotPair()
|
||||
getNotToContainPair()
|
||||
) {
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getNotOrAtMostTriple() =
|
||||
{ what: String, times: String -> "$contains $what $notOrAtMost $times" } to
|
||||
("$contains $filler $notOrAtMost" to Companion::containsNotOrAtMost)
|
||||
{ what: String, times: String -> "$toContain $what $notOrAtMost $times" } to
|
||||
("$toContain $filler $notOrAtMost" to Companion::notToContainOrAtMost)
|
||||
|
||||
private fun containsNotOrAtMost(
|
||||
private fun notToContainOrAtMost(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
atMost: Int,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
) =
|
||||
if (aX.isEmpty()) expect contains o inAny order notOrAtMost atMost value a
|
||||
else expect contains o inAny order notOrAtMost atMost the values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inAny order notOrAtMost atMost value a
|
||||
else expect toContain o inAny order notOrAtMost atMost the values(a, *aX)
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot
|
||||
private fun getNotToContainPair() = notToContain to Companion::getErrorMsgNotToContain
|
||||
|
||||
private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$notOrAtMost $times`"
|
||||
private fun getErrorMsgNotToContain(times: Int) = "use `$notToContain` instead of `$notOrAtMost $times`"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,27 +10,27 @@ class IterableToContainInAnyOrderOnlyEntriesExpectationsSpec :
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyEntries" to Companion::containsInAnyOrderOnlyEntries
|
||||
"$toContain $filler $inAnyOrder $butOnly $inAnyOrderOnlyEntries" to Companion::toContainInAnyOrderOnlyEntries
|
||||
|
||||
private fun containsInAnyOrderOnlyEntries(
|
||||
private fun toContainInAnyOrderOnlyEntries(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order but only entry a
|
||||
else expect contains o inAny order but only the entries(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inAny order but only entry a
|
||||
else expect toContain o inAny order but only the entries(a, *aX)
|
||||
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyEntries" to Companion::containsInAnyOrderOnlyNullableEntries
|
||||
"$toContain $filler $inAnyOrder $butOnly $inAnyOrderOnlyEntries" to Companion::toContainInAnyOrderOnlyNullableEntries
|
||||
|
||||
private fun containsInAnyOrderOnlyNullableEntries(
|
||||
private fun toContainInAnyOrderOnlyNullableEntries(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order but only entry a
|
||||
else expect contains o inAny order but only the entries(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inAny order but only entry a
|
||||
else expect toContain o inAny order but only the entries(a, *aX)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,27 +10,27 @@ class IterableToContainInAnyOrderOnlyValuesExpectationsSpec :
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyValues" to Companion::containsInAnyOrderOnlyValues
|
||||
"$toContain $filler $inAnyOrder $butOnly $inAnyOrderOnlyValues" to Companion::toContainInAnyOrderOnlyValues
|
||||
|
||||
private fun containsInAnyOrderOnlyValues(
|
||||
private fun toContainInAnyOrderOnlyValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order but only value a
|
||||
else expect contains o inAny order but only the values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inAny order but only value a
|
||||
else expect toContain o inAny order but only the values(a, *aX)
|
||||
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyValues" to Companion::containsInAnyOrderOnlyNullableValues
|
||||
"$toContain $filler $inAnyOrder $butOnly $inAnyOrderOnlyValues" to Companion::toContainInAnyOrderOnlyNullableValues
|
||||
|
||||
private fun containsInAnyOrderOnlyNullableValues(
|
||||
private fun toContainInAnyOrderOnlyNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order but only value a
|
||||
else expect contains o inAny order but only the values(a, *aX)
|
||||
if (aX.isEmpty()) expect toContain o inAny order but only value a
|
||||
else expect toContain o inAny order but only the values(a, *aX)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@ class IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec :
|
||||
) {
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::containsInOrderOnlyGroupedInAnyOrderEntries
|
||||
"$toContain $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::toContainInOrderOnlyGroupedInAnyOrderEntries
|
||||
|
||||
private fun containsInOrderOnlyGroupedInAnyOrderEntries(
|
||||
private fun toContainInOrderOnlyGroupedInAnyOrderEntries(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a1: Group<(Expect<Double>.() -> Unit)?>,
|
||||
a2: Group<(Expect<Double>.() -> Unit)?>,
|
||||
aX: Array<out Group<(Expect<Double>.() -> Unit)?>>
|
||||
): Expect<Iterable<Double?>> =
|
||||
expect contains o inGiven order and only grouped entries within group inAny order(a1, a2, *aX)
|
||||
expect toContain o inGiven order and only grouped entries within group inAny order(a1, a2, *aX)
|
||||
|
||||
private fun groupFactory(groups: Array<out (Expect<Double>.() -> Unit)?>) =
|
||||
when (groups.size) {
|
||||
|
||||
@@ -13,15 +13,15 @@ class IterableToContainInOrderOnlyGroupedValuesExpectationsSpec :
|
||||
) {
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::containsInOrderOnlyGroupedInAnyOrderValues
|
||||
"$toContain $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::toContainInOrderOnlyGroupedInAnyOrderValues
|
||||
|
||||
private fun containsInOrderOnlyGroupedInAnyOrderValues(
|
||||
private fun toContainInOrderOnlyGroupedInAnyOrderValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a1: Group<Double>,
|
||||
a2: Group<Double>,
|
||||
aX: Array<out Group<Double>>
|
||||
): Expect<Iterable<Double>> =
|
||||
expect contains o inGiven order and only grouped entries within group inAny order(a1, a2, *aX)
|
||||
expect toContain o inGiven order and only grouped entries within group inAny order(a1, a2, *aX)
|
||||
|
||||
private fun groupFactory(groups: Array<out Double>): Group<Double> =
|
||||
when (groups.size) {
|
||||
@@ -34,15 +34,15 @@ class IterableToContainInOrderOnlyGroupedValuesExpectationsSpec :
|
||||
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::containsInOrderOnlyGroupedInAnyOrderNullableValues
|
||||
"$toContain $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::toContainInOrderOnlyGroupedInAnyOrderNullableValues
|
||||
|
||||
private fun containsInOrderOnlyGroupedInAnyOrderNullableValues(
|
||||
private fun toContainInOrderOnlyGroupedInAnyOrderNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a1: Group<Double?>,
|
||||
a2: Group<Double?>,
|
||||
aX: Array<out Group<Double?>>
|
||||
): Expect<Iterable<Double?>> =
|
||||
expect contains o inGiven order and only grouped entries within group inAny order(a1, a2, *aX)
|
||||
expect toContain o inGiven order and only grouped entries within group inAny order(a1, a2, *aX)
|
||||
|
||||
private fun nullableGroupFactory(groups: Array<out Double?>): Group<Double?> =
|
||||
when (groups.size) {
|
||||
|
||||
@@ -5,9 +5,9 @@ import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
|
||||
class IterableAllExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableAllExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::all),
|
||||
fun1(Expect<Iterable<Double?>>::all).withNullableSuffix()
|
||||
class IterableToHaveNextAndAllExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAllExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndAll),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndAll).withNullableSuffix()
|
||||
) {
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
@@ -17,11 +17,11 @@ class IterableAllExpectationsSpec : ch.tutteli.atrium.specs.integration.Iterable
|
||||
|
||||
var star: Expect<Iterable<*>> = notImplemented()
|
||||
|
||||
a1 = a1 all {}
|
||||
a1 = a1 toHaveNextAndAll {}
|
||||
|
||||
a1b = a1b all {}
|
||||
a1b = a1b all null
|
||||
a1b = a1b toHaveNextAndAll {}
|
||||
a1b = a1b toHaveNextAndAll null
|
||||
|
||||
star = star all {}
|
||||
star = star toHaveNextAndAll {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
|
||||
class IterableToHaveNextAndNoneExpectationsSpec : Spek({
|
||||
|
||||
include(PredicateSpec)
|
||||
include(BuilderSpec)
|
||||
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndNoneExpectationsSpec(
|
||||
fun1(Expect<Iterable<Double>>::toHaveNextAndNone),
|
||||
fun1(Expect<Iterable<Double?>>::toHaveNextAndNone).withNullableSuffix(),
|
||||
"[Atrium][Predicate] "
|
||||
)
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndNoneExpectationsSpec(
|
||||
getNotToContainPair(),
|
||||
getNotToContainNullablePair().withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getNotToContainPair() = notToContain to Companion::notToContainFun
|
||||
|
||||
private fun notToContainFun(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect notToContain o entry a
|
||||
|
||||
private fun getNotToContainNullablePair() = notToContain to Companion::notToContainNullableFun
|
||||
|
||||
private fun notToContainNullableFun(expect: Expect<Iterable<Double?>>, a: (Expect<Double>.() -> Unit)?) =
|
||||
expect notToContain o entry a
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<List<Double>> = notImplemented()
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1.toHaveNextAndNone {}
|
||||
a1 = a1 notToContain o entry {}
|
||||
|
||||
a1b = a1b toHaveNextAndNone {}
|
||||
a1b = a1b toHaveNextAndNone null
|
||||
a1b = a1b notToContain o entry {}
|
||||
a1b = a1b notToContain o entry null
|
||||
|
||||
star = star.toHaveNextAndNone {}
|
||||
star = star notToContain o entry {}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import ch.tutteli.atrium.reporting.translating.Translatable
|
||||
* defines which [Checker]s should be applied and
|
||||
* is finalized by one of the [IterableLikeContainsAssertions] which usually use a [Creator].
|
||||
*/
|
||||
//TODO 0.18.0 use IterableLikeToContains in combinatino with proof
|
||||
interface IterableLikeContains {
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ import ch.tutteli.atrium.logic.utils.expectLambda
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.translations.DescriptionIterableAssertion
|
||||
|
||||
abstract class IterableAllExpectationsSpec(
|
||||
abstract class IterableToHaveNextAndAllExpectationsSpec(
|
||||
notToBeEmptyAndAll: Fun1<Iterable<Double>, Expect<Double>.() -> Unit>,
|
||||
notToBeEmptyAndAllNullable: Fun1<Iterable<Double?>, (Expect<Double>.() -> Unit)?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
@@ -6,7 +6,7 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.translations.DescriptionComparableAssertion
|
||||
|
||||
abstract class IterableAnyExpectationsSpec(
|
||||
abstract class IterableToHaveNextAndAnyExpectationsSpec(
|
||||
notToBeEmptyAndAny: Fun1<Iterable<Double>, Expect<Double>.() -> Unit>,
|
||||
notToBeEmptyAndAnyNullable: Fun1<Iterable<Double?>, (Expect<Double>.() -> Unit)?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
@@ -6,7 +6,7 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.translations.DescriptionIterableAssertion
|
||||
|
||||
abstract class IterableNoneExpectationsSpec(
|
||||
abstract class IterableToHaveNextAndNoneExpectationsSpec(
|
||||
notToBeEmptyAndNone: Fun1<Iterable<Double>, Expect<Double>.() -> Unit>,
|
||||
notToBeEmptyAndNoneNullable: Fun1<Iterable<Double?>, (Expect<Double>.() -> Unit)?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
Reference in New Issue
Block a user