From d67ff9638897d6c06cb731be543b291d42bf0207 Mon Sep 17 00:00:00 2001 From: Robert Stoll Date: Wed, 28 Apr 2021 21:25:09 +0200 Subject: [PATCH] rename iterable assertion functions to new schema in api-infix cannot rename all files because of git mv incapabilities. Would loose history otherwise. --- ...erableToHaveNextAndAllExpectationsSpec.kt} | 2 +- ...erableToHaveNextAndAnyExpectationsSpec.kt} | 12 +- ...rableToHaveNextAndNoneExpectationsSpec.kt} | 8 +- .../api/infix/en_GB/iterableAssertions.kt | 6 + .../api/infix/en_GB/iterableExpectations.kt | 334 ++++++++++++++ .../atrium/api/infix/en_GB/keywords.kt | 31 +- .../en_GB/IterableAnyExpectationsSpec.kt | 94 ++-- ...OrderAtLeast1ElementsOfExpectationsSpec.kt | 54 +-- ...AnyOrderAtLeast1EntriesExpectationsSpec.kt | 54 +-- ...nAnyOrderAtLeast1ValuesExpectationsSpec.kt | 54 +-- ...nAnyOrderOnlyElementsOfExpectationsSpec.kt | 26 +- ...nsInOrderOnlyElementsOfExpectationsSpec.kt | 58 +-- ...tainsInOrderOnlyEntriesExpectationsSpec.kt | 58 +-- ...ntainsInOrderOnlyValuesExpectationsSpec.kt | 56 +-- ...erableContainsNotValuesExpectationsSpec.kt | 38 +- .../infix/en_GB/IterableContainsSpecBase.kt | 407 +++++++++--------- .../infix/en_GB/IterableExpectationsSpec.kt | 18 +- .../en_GB/IterableNoneExpectationsSpec.kt | 58 --- ...ableNotToContainEntriesExpectationsSpec.kt | 20 +- ...InAnyOrderAtLeastValuesExpectationsSpec.kt | 24 +- ...nInAnyOrderAtMostValuesExpectationsSpec.kt | 16 +- ...InAnyOrderExactlyValuesExpectationsSpec.kt | 10 +- ...yOrderNotOrAtMostValuesExpectationsSpec.kt | 16 +- ...inInAnyOrderOnlyEntriesExpectationsSpec.kt | 16 +- ...ainInAnyOrderOnlyValuesExpectationsSpec.kt | 16 +- ...OrderOnlyGroupedEntriesExpectationsSpec.kt | 6 +- ...nOrderOnlyGroupedValuesExpectationsSpec.kt | 12 +- ...erableToHaveNextAndAllExpectationsSpec.kt} | 14 +- ...erableToHaveNextAndNoneExpectationsSpec.kt | 58 +++ .../iterable/contains/IterableLikeContains.kt | 1 + ...erableToHaveNextAndAllExpectationsSpec.kt} | 2 +- ...erableToHaveNextAndAnyExpectationsSpec.kt} | 2 +- ...rableToHaveNextAndNoneExpectationsSpec.kt} | 2 +- 33 files changed, 967 insertions(+), 616 deletions(-) rename apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/{IterableAllExpectationsSpec.kt => IterableToHaveNextAndAllExpectationsSpec.kt} (86%) rename apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/{IterableAnyExpectationsSpec.kt => IterableToHaveNextAndAnyExpectationsSpec.kt} (92%) rename apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/{IterableNoneExpectationsSpec.kt => IterableToHaveNextAndNoneExpectationsSpec.kt} (88%) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableExpectations.kt delete mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneExpectationsSpec.kt rename apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/{IterableAllExpectationsSpec.kt => IterableToHaveNextAndAllExpectationsSpec.kt} (53%) create mode 100644 apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToHaveNextAndNoneExpectationsSpec.kt rename misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/{IterableAllExpectationsSpec.kt => IterableToHaveNextAndAllExpectationsSpec.kt} (98%) rename misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/{IterableAnyExpectationsSpec.kt => IterableToHaveNextAndAnyExpectationsSpec.kt} (99%) rename misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/{IterableNoneExpectationsSpec.kt => IterableToHaveNextAndNoneExpectationsSpec.kt} (99%) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToHaveNextAndAllExpectationsSpec.kt similarity index 86% rename from apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllExpectationsSpec.kt rename to apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToHaveNextAndAllExpectationsSpec.kt index 8739b5a2d..7f96d9799 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAllExpectationsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToHaveNextAndAllExpectationsSpec.kt @@ -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>::toHaveNextAndAll), fun1(Expect>::toHaveNextAndAll).withNullableSuffix() ) { diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToHaveNextAndAnyExpectationsSpec.kt similarity index 92% rename from apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyExpectationsSpec.kt rename to apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToHaveNextAndAnyExpectationsSpec.kt index 31b7edcd9..999f8e1d1 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableAnyExpectationsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToHaveNextAndAnyExpectationsSpec.kt @@ -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>::toHaveNextAndAny), fun1(Expect>::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] " diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToHaveNextAndNoneExpectationsSpec.kt similarity index 88% rename from apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneExpectationsSpec.kt rename to apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToHaveNextAndNoneExpectationsSpec.kt index 56295ef79..a7a3350fc 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableNoneExpectationsSpec.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToHaveNextAndNoneExpectationsSpec.kt @@ -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>::toHaveNextAndNone), fun1(Expect>::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] " diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt index 6eee6d1eb..2ccefd127 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableAssertions.kt @@ -241,6 +241,7 @@ infix fun > Expect.containsNot(expected: E): Expect = infix fun > Expect.containsNot(values: Values): Expect = 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 > Expect.containsNot(values: Values): Expect< infix fun , T : Iterable> Expect.min(@Suppress("UNUSED_PARAMETER") o: o): Expect = _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 , T : Iterable> Expect.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 , T : Iterable> Expect.min(assertionCreator: E infix fun , T : Iterable> Expect.max(@Suppress("UNUSED_PARAMETER") o: o): Expect = _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 > Expect.hasNot(@Suppress("UNUSED_PARAMETER") ne infix fun > Expect.contains(@Suppress("UNUSED_PARAMETER") noDuplicates: noDuplicates): Expect = _logicAppend { containsNoDuplicates(::identity) } +//TODO 0.18.0 move to iterableExpectations.kt /** * Turns `Expect>` into `Expect`. * @@ -373,6 +378,7 @@ infix fun > Expect.asList( @Suppress("UNUSED_PARAMETER") o: o ): Expect> = _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]. diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableExpectations.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableExpectations.kt new file mode 100644 index 000000000..cb911ec78 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableExpectations.kt @@ -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 > Expect.toContain( + @Suppress("UNUSED_PARAMETER") o: o +): IterableLikeContains.EntryPointStep = _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 > Expect.notToContain( + @Suppress("UNUSED_PARAMETER") o: o +): NotCheckerStep = _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 > Expect.toContain(expected: E): Expect = + 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 > Expect.toContain(values: Values): Expect = + 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 > Expect.toContain(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = + 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 > Expect.toContain(entries: Entries): Expect = + 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 > Expect.toContainExactly(expected: E): Expect = + 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 > Expect.toContainExactly(values: Values): Expect = + 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 > Expect.toContainExactly( + assertionCreatorOrNull: (Expect.() -> Unit)? +): Expect = 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 > Expect.toContainExactly(entries: Entries): Expect = + 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 > Expect.toContainExactlyElementsOf( + expectedIterableLike: IterableLike +): Expect = 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 > Expect.toContainElementsOf( + expectedIterableLike: IterableLike +): Expect = 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 > Expect.notToContain(expected: E): Expect = + 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 > Expect.notToContain(values: Values): Expect = + 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 > Expect.toHaveNextAndAny(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = + 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 > Expect.toHaveNextAndNone(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = + 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 > Expect.toHaveNextAndAll(assertionCreatorOrNull: (Expect.() -> Unit)?): Expect = + _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 > Expect.toHave(@Suppress("UNUSED_PARAMETER") next: next): Expect = + _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 > Expect.notToHave(@Suppress("UNUSED_PARAMETER") next: next): Expect = + _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 > Expect.notToContain(@Suppress("UNUSED_PARAMETER") duplicates: duplicates): Expect = + _logicAppend { containsNoDuplicates(::identity) } + diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt index 02834940a..c27a08f82 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/keywords.kt @@ -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 diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyExpectationsSpec.kt index f439cd98c..8a5a782df 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAnyExpectationsSpec.kt @@ -15,76 +15,76 @@ class IterableAnyExpectationsSpec : Spek({ include(ShortcutSpec) include(SequenceSpec) }) { - object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableAnyExpectationsSpec( - fun1(Expect>::any), - fun1(Expect>::any).withNullableSuffix(), + object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAnyExpectationsSpec( + fun1(Expect>::toHaveNextAndAny), + fun1(Expect>::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>, a: Expect.() -> Unit) = - expect contains o inAny order atLeast 1 entry a + private fun toContainInAnyOrderEntry(expect: Expect>, a: Expect.() -> 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>, a: (Expect.() -> Unit)?) = - expect contains o inAny order atLeast 1 entry a + private fun toContainNullableEntry(expect: Expect>, a: (Expect.() -> Unit)?) = + expect toContain o inAny order atLeast 1 entry a - private val containsShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = - Expect>::contains + private val toContainShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = + Expect>::toContain - fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntryShortcut + fun getToContainShortcutPair() = toContainShortcutFun.name to Companion::toContainInAnyOrderEntryShortcut - private fun containsInAnyOrderEntryShortcut(expect: Expect>, a: Expect.() -> Unit) = - expect contains a + private fun toContainInAnyOrderEntryShortcut(expect: Expect>, a: Expect.() -> Unit) = + expect toContain a - private val containsShortcutNullableFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = - Expect>::contains + private val toContainShortcutNullableFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = + Expect>::toContain - fun getContainsNullableShortcutPair() = - containsShortcutNullableFun.name to Companion::containsNullableEntryShortcut + fun getToContainNullableShortcutPair() = + toContainShortcutNullableFun.name to Companion::toContainNullableEntryShortcut - private fun containsNullableEntryShortcut( + private fun toContainNullableEntryShortcut( expect: Expect>, a: (Expect.() -> 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>, a: Expect.() -> Unit) = - expect._logic.changeSubject.unreported { it.asSequence() } asIterable o contains a + private fun toContainInAnyOrderEntrySequence(expect: Expect>, a: Expect.() -> 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>, a: (Expect.() -> 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> = 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 {} } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ElementsOfExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ElementsOfExpectationsSpec.kt index 09fbb6ac3..ba21ac698 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ElementsOfExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ElementsOfExpectationsSpec.kt @@ -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>( - "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>( - "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>, a: Double, aX: Array - ): Expect> = expect contains o inAny order atLeast 1 elementsOf listOf(a, *aX) + ): Expect> = 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>, a: Double?, aX: Array - ): Expect> = expect contains o inAny order atLeast 1 elementsOf sequenceOf(a, *aX) + ): Expect> = expect toContain o inAny order atLeast 1 elementsOf sequenceOf(a, *aX) - private val containsElementsOfShortcutFun: KFunction2>, Iterable, Expect>> = - Expect>::containsElementsOf + private val toContainElementsOfShortcutFun: KFunction2>, Iterable, Expect>> = + Expect>::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>, a: Double, aX: Array - ): Expect> = expect containsElementsOf arrayOf(a, *aX) + ): Expect> = expect toContainElementsOf arrayOf(a, *aX) - private val containsElementsOfNullableShortcutFun: KFunction2>, Iterable, Expect>> = - Expect>::containsElementsOf + private val toContainElementsOfNullableShortcutFun: KFunction2>, Iterable, Expect>> = + Expect>::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>, a: Double?, aX: Array - ): Expect> = expect containsElementsOf sequenceOf(a, *aX).asIterable() + ): Expect> = expect toContainElementsOf sequenceOf(a, *aX).asIterable() } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesExpectationsSpec.kt index 752efbf41..038781bcb 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1EntriesExpectationsSpec.kt @@ -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>, a: Expect.() -> Unit, aX: Array.() -> Unit> ): Expect> = - 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>, a: (Expect.() -> Unit)?, aX: Array.() -> Unit)?> ): Expect> = - 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.() -> Unit, Expect>> = - Expect>::contains + private val toContainShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = + Expect>::toContain - fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntriesShortcut + fun getToContainShortcutPair() = toContainShortcutFun.name to Companion::toContainInAnyOrderEntriesShortcut - private fun containsInAnyOrderEntriesShortcut( + private fun toContainInAnyOrderEntriesShortcut( expect: Expect>, a: Expect.() -> Unit, aX: Array.() -> Unit> ): Expect> = - 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.() -> Unit)?, Expect>> = - Expect>::contains + private val toContainEntriesFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = + Expect>::toContain - fun getContainsNullableShortcutPair() = containsEntriesFun.name to Companion::containsNullableEntriesShortcut + fun getToContainNullableShortcutPair() = toContainEntriesFun.name to Companion::toContainNullableEntriesShortcut - private fun containsNullableEntriesShortcut( + private fun toContainNullableEntriesShortcut( expect: Expect>, a: (Expect.() -> Unit)?, aX: Array.() -> Unit)?> ): Expect> = - if (aX.isEmpty()) expect contains a - else expect contains entries(a, *aX) + if (aX.isEmpty()) expect toContain a + else expect toContain entries(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesExpectationsSpec.kt index d6b28adfa..44841176e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderAtLeast1ValuesExpectationsSpec.kt @@ -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>, a: Double, aX: Array ): Expect> = - 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>, a: Double?, aX: Array ): Expect> = - 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>, Double, Expect>> = - Expect>::contains + private val toContainFun: KFunction2>, Double, Expect>> = + Expect>::toContain - fun getContainsShortcutPair() = containsFun.name to Companion::containsValuesShortcut + fun getToContainShortcutPair() = toContainFun.name to Companion::toContainValuesShortcut - private fun containsValuesShortcut( + private fun toContainValuesShortcut( expect: Expect>, a: Double, aX: Array ): Expect> = - 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>, Double?, Expect>> = - Expect>::contains + private val toContainNullableFun: KFunction2>, Double?, Expect>> = + Expect>::toContain - fun getContainsNullableShortcutPair() = containsNullableFun.name to Companion::containsNullableValuesShortcut + fun getToContainNullableShortcutPair() = toContainNullableFun.name to Companion::toContainNullableValuesShortcut - private fun containsNullableValuesShortcut( + private fun toContainNullableValuesShortcut( expect: Expect>, a: Double?, aX: Array ): Expect> = - if (aX.isEmpty()) expect contains a - else expect contains values(a, *aX) + if (aX.isEmpty()) expect toContain a + else expect toContain values(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyElementsOfExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyElementsOfExpectationsSpec.kt index 79ca99f1a..e04686967 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyElementsOfExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInAnyOrderOnlyElementsOfExpectationsSpec.kt @@ -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>( - "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>, a: Double, aX: Array - ): Expect> = expect contains o inAny order but only elementsOf listOf(a, *aX) + ): Expect> = 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>, a: Double?, aX: Array - ): Expect> = expect contains o inAny order but only elementsOf sequenceOf(a, *aX) + ): Expect> = expect toContain o inAny order but only elementsOf sequenceOf(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyElementsOfExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyElementsOfExpectationsSpec.kt index 7726a96f7..a7aa30bc8 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyElementsOfExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyElementsOfExpectationsSpec.kt @@ -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>( - "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>( - "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>, a: Double, aX: Array - ): Expect> = expect contains o inGiven order and only elementsOf listOf(a, *aX) + ): Expect> = 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>, a: Double?, aX: Array - ): Expect> = expect contains o inGiven order and only elementsOf sequenceOf(a, *aX) + ): Expect> = expect toContain o inGiven order and only elementsOf sequenceOf(a, *aX) - private val containsExactlyElementsOfShortcutFun: KFunction2>, Iterable, Expect>> = - Expect>::containsExactlyElementsOf + private val toContainExactlyElementsOfShortcutFun: KFunction2>, Iterable, Expect>> = + Expect>::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>, a: Double, aX: Array - ): Expect> = expect containsExactlyElementsOf arrayOf(a, *aX) + ): Expect> = expect toContainExactlyElementsOf arrayOf(a, *aX) - private val containsExactlyElementsOfNullableShortcutFun: KFunction2>, Iterable, Expect>> = - Expect>::containsExactlyElementsOf + private val toContainExactlyElementsOfNullableShortcutFun: KFunction2>, Iterable, Expect>> = + Expect>::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>, a: Double?, aX: Array - ): Expect> = expect containsExactlyElementsOf sequenceOf(a, *aX).asIterable() + ): Expect> = expect toContainExactlyElementsOf sequenceOf(a, *aX).asIterable() } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesExpectationsSpec.kt index 5a211bd35..5402622e7 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyEntriesExpectationsSpec.kt @@ -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>, a: Expect.() -> Unit, aX: Array.() -> Unit> ): Expect> = - 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>, a: (Expect.() -> Unit)?, aX: Array.() -> Unit)?> ): Expect> = - 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.() -> Unit, Expect>> = - Expect>::containsExactly + private val toContainShortcutFun: KFunction2>, Expect.() -> Unit, Expect>> = + Expect>::toContainExactly - fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInOrderOnlyEntriesShortcut + fun getToContainShortcutPair() = toContainShortcutFun.name to Companion::toContainInOrderOnlyEntriesShortcut - private fun containsInOrderOnlyEntriesShortcut( + private fun toContainInOrderOnlyEntriesShortcut( expect: Expect>, a: Expect.() -> Unit, aX: Array.() -> Unit> ): Expect> = - 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.() -> Unit)?, Expect>> = - Expect>::containsExactly + private val toContainNullableShortcutFun: KFunction2>, (Expect.() -> Unit)?, Expect>> = + Expect>::toContainExactly - fun getContainsNullableShortcutPair() = - containsNullableShortcutFun.name to Companion::containsInOrderOnlyNullableEntriesShortcut + fun getToContainNullableShortcutPair() = + toContainNullableShortcutFun.name to Companion::toContainInOrderOnlyNullableEntriesShortcut - private fun containsInOrderOnlyNullableEntriesShortcut( + private fun toContainInOrderOnlyNullableEntriesShortcut( expect: Expect>, a: (Expect.() -> Unit)?, aX: Array.() -> Unit)?> ): Expect> = 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) } } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesExpectationsSpec.kt index 7214500e5..156007e60 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsInOrderOnlyValuesExpectationsSpec.kt @@ -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>, a: Double, aX: Array ): Expect> = - 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>, a: Double?, aX: Array ): Expect> = - 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>, Double, Expect>> = - Expect>::containsExactly + private val toContainShortcutFun: KFunction2>, Double, Expect>> = + Expect>::toContainExactly - fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInOrderOnlyValuesShortcut + fun getToContainShortcutPair() = toContainShortcutFun.name to Companion::toContainInOrderOnlyValuesShortcut - private fun containsInOrderOnlyValuesShortcut( + private fun toContainInOrderOnlyValuesShortcut( expect: Expect>, a: Double, aX: Array ): Expect> = - 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>, Double?, Expect>> = - Expect>::containsExactly + private val toContainNullableShortcutFun: KFunction2>, Double?, Expect>> = + Expect>::toContainExactly - fun getContainsNullableShortcutPair() = - containsNullableShortcutFun.name to Companion::containsInOrderOnlyNullableValuesShortcut + fun getToContainNullableShortcutPair() = + toContainNullableShortcutFun.name to Companion::toContainInOrderOnlyNullableValuesShortcut - private fun containsInOrderOnlyNullableValuesShortcut( + private fun toContainInOrderOnlyNullableValuesShortcut( expect: Expect>, a: Double?, aX: Array ): Expect> = - if (aX.isEmpty()) expect containsExactly a - else expect containsExactly values(a, *aX) + if (aX.isEmpty()) expect toContainExactly a + else expect toContainExactly values(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesExpectationsSpec.kt index 6be4a1b0d..4c49e967e 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsNotValuesExpectationsSpec.kt @@ -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>, a: Double, aX: Array ): Expect> = - 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>, a: Double?, aX: Array ): Expect> = - 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>, Double, Expect>> = - Expect>::containsNot + private val notToContainShortcutFun: KFunction2>, Double, Expect>> = + Expect>::notToContain - private fun getContainsNotShortcutPair() = containsNotShortcutFun.name to Companion::containsNotShortcut + private fun getNotToContainShortcutPair() = notToContainShortcutFun.name to Companion::notToContainShortcut - private fun containsNotShortcut(expect: Expect>, a: Double, aX: Array) = - if (aX.isEmpty()) expect containsNot a - else expect containsNot values(a, *aX) + private fun notToContainShortcut(expect: Expect>, a: Double, aX: Array) = + if (aX.isEmpty()) expect notToContain a + else expect notToContain values(a, *aX) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt index 570e8e0db..2b861c382 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableContainsSpecBase.kt @@ -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>, o, IterableLikeContains.EntryPointStep, NoOpSearchBehaviour>> = - Expect>::contains - protected val contains = containsProp.name - private val containsNotProp: KFunction2>, o, NotCheckerStep, NotSearchBehaviour>> = - Expect>::containsNot - protected val containsNot = "${containsNotProp.name} $Values" + private val toContainProp: KFunction2>, o, IterableLikeContains.EntryPointStep, NoOpSearchBehaviour>> = + Expect>::toContain + protected val toContain = toContainProp.name + private val notToContainProp: KFunction2>, o, NotCheckerStep, NotSearchBehaviour>> = + Expect>::notToContain + protected val notToContain = "${notToContainProp.name} $Values" @Suppress("unused") private fun ambiguityTest() { @@ -77,236 +78,236 @@ abstract class IterableContainsSpecBase { val star: Expect> = notImplemented() val any: Expect> = 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.() -> Unit)?) - nullableList containsExactly entries({}, null) - nullableList containsExactly entries(null, {}) - nullableList containsExactly entries(null, null) + nullableList toContainExactly (null as (Expect.() -> 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.() -> Unit)?) - star containsExactly entries({}, null) - star containsExactly entries(null, {}) - star containsExactly entries(null, null) + star toContainExactly (null as (Expect.() -> 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(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(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 {}, 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 {}, 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(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(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(null), entries(null), diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableExpectationsSpec.kt index c390aff6a..2f4c9ebef 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableExpectationsSpec.kt @@ -11,7 +11,7 @@ class IterableExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableExp fun1, Expect.() -> Unit>(Expect>::min), maxFeaturePair(), fun1, Expect.() -> Unit>(Expect>::max), - getContainsNoDuplicatesPair() + getToContainNoDuplicatesPair() ) { companion object { private val has: KFunction2>, next, Expect>> = Expect>::has @@ -30,13 +30,13 @@ class IterableExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableExp private fun maxFeaturePair() = feature1, o, Int>(Expect>::min).name to ::maxFeature private fun maxFeature(expect: Expect>) = expect max o - private val containsDuplicates: KFunction2>, noDuplicates, Expect>> = - Expect>::contains + private val notToContainDuplicates: KFunction2>, duplicates, Expect>> = + Expect>::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>) = expect contains noDuplicates + private fun toContainNoDuplicates(expect: Expect>) = 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 does not exist for T? (one cannot implement an interface for the nullable type) //same for Iterable<*> diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneExpectationsSpec.kt deleted file mode 100644 index 1d2b574b5..000000000 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNoneExpectationsSpec.kt +++ /dev/null @@ -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>::none), - fun1(Expect>::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>, a: Expect.() -> Unit) = - expect containsNot o entry a - - private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun - - private fun containsNotNullableFun(expect: Expect>, a: (Expect.() -> Unit)?) = - expect containsNot o entry a - } - - @Suppress("unused", "UNUSED_VALUE") - private fun ambiguityTest() { - var a1: Expect> = notImplemented() - var a1b: Expect> = notImplemented() - - var star: Expect> = 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 {} - } -} diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNotToContainEntriesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNotToContainEntriesExpectationsSpec.kt index 72dd4e180..a66b39eaa 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNotToContainEntriesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableNotToContainEntriesExpectationsSpec.kt @@ -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>, a: Expect.() -> Unit, aX: Array.() -> Unit> ): Expect> = - 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>, a: (Expect.() -> Unit)?, aX: Array.() -> Unit)?> ): Expect> = - 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) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderAtLeastValuesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderAtLeastValuesExpectationsSpec.kt index 2c954ec89..a2d7fb1b5 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderAtLeastValuesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderAtLeastValuesExpectationsSpec.kt @@ -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>, atLeast: Int, a: Double, aX: Array ): Expect> = - 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>, atLeast: Int, butAtMost: Int, a: Double, aX: Array - ) = 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 diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderAtMostValuesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderAtMostValuesExpectationsSpec.kt index 59bc6a98a..4957da14b 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderAtMostValuesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderAtMostValuesExpectationsSpec.kt @@ -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>, atMost: Int, a: Double, aX: Array) = - 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>, atMost: Int, a: Double, aX: Array) = + 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 diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderExactlyValuesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderExactlyValuesExpectationsSpec.kt index 0b73a6d55..5f71f6357 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderExactlyValuesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderExactlyValuesExpectationsSpec.kt @@ -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>, @@ -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`" } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderNotOrAtMostValuesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderNotOrAtMostValuesExpectationsSpec.kt index ad790109a..5599a6d09 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderNotOrAtMostValuesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderNotOrAtMostValuesExpectationsSpec.kt @@ -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>, atMost: Int, a: Double, aX: Array ) = - 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`" } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderOnlyEntriesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderOnlyEntriesExpectationsSpec.kt index 776d1bb4f..fbf1f01ea 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderOnlyEntriesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderOnlyEntriesExpectationsSpec.kt @@ -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>, a: Expect.() -> Unit, aX: Array.() -> Unit> ): Expect> = - 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>, a: (Expect.() -> Unit)?, aX: Array.() -> Unit)?> ): Expect> = - 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) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderOnlyValuesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderOnlyValuesExpectationsSpec.kt index ed45b6b57..d5dcd0e63 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderOnlyValuesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInAnyOrderOnlyValuesExpectationsSpec.kt @@ -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>, a: Double, aX: Array ): Expect> = - 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>, a: Double?, aX: Array ): Expect> = - 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) } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec.kt index 9566d35cf..4d807f228 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec.kt @@ -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>, a1: Group<(Expect.() -> Unit)?>, a2: Group<(Expect.() -> Unit)?>, aX: Array.() -> Unit)?>> ): Expect> = - 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.() -> Unit)?>) = when (groups.size) { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInOrderOnlyGroupedValuesExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInOrderOnlyGroupedValuesExpectationsSpec.kt index 8c56378ab..6d54782bc 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInOrderOnlyGroupedValuesExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToContainInOrderOnlyGroupedValuesExpectationsSpec.kt @@ -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>, a1: Group, a2: Group, aX: Array> ): Expect> = - 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): Group = 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>, a1: Group, a2: Group, aX: Array> ): Expect> = - 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): Group = when (groups.size) { diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToHaveNextAndAllExpectationsSpec.kt similarity index 53% rename from apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllExpectationsSpec.kt rename to apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToHaveNextAndAllExpectationsSpec.kt index d214054e1..ab6c9e289 100644 --- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableAllExpectationsSpec.kt +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToHaveNextAndAllExpectationsSpec.kt @@ -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>::all), - fun1(Expect>::all).withNullableSuffix() +class IterableToHaveNextAndAllExpectationsSpec : ch.tutteli.atrium.specs.integration.IterableToHaveNextAndAllExpectationsSpec( + fun1(Expect>::toHaveNextAndAll), + fun1(Expect>::toHaveNextAndAll).withNullableSuffix() ) { @Suppress("unused", "UNUSED_VALUE") @@ -17,11 +17,11 @@ class IterableAllExpectationsSpec : ch.tutteli.atrium.specs.integration.Iterable var star: Expect> = 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 {} } } diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToHaveNextAndNoneExpectationsSpec.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToHaveNextAndNoneExpectationsSpec.kt new file mode 100644 index 000000000..ebacab9f5 --- /dev/null +++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/infix/en_GB/IterableToHaveNextAndNoneExpectationsSpec.kt @@ -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>::toHaveNextAndNone), + fun1(Expect>::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>, a: Expect.() -> Unit) = + expect notToContain o entry a + + private fun getNotToContainNullablePair() = notToContain to Companion::notToContainNullableFun + + private fun notToContainNullableFun(expect: Expect>, a: (Expect.() -> Unit)?) = + expect notToContain o entry a + } + + @Suppress("unused", "UNUSED_VALUE") + private fun ambiguityTest() { + var a1: Expect> = notImplemented() + var a1b: Expect> = notImplemented() + + var star: Expect> = 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 {} + } +} diff --git a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/IterableLikeContains.kt b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/IterableLikeContains.kt index 67b1b19b4..bbc86c082 100644 --- a/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/IterableLikeContains.kt +++ b/logic/atrium-logic-common/src/main/kotlin/ch/tutteli/atrium/logic/creating/iterable/contains/IterableLikeContains.kt @@ -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 { /** diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllExpectationsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableToHaveNextAndAllExpectationsSpec.kt similarity index 98% rename from misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllExpectationsSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableToHaveNextAndAllExpectationsSpec.kt index 9998768a2..91db84d11 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAllExpectationsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableToHaveNextAndAllExpectationsSpec.kt @@ -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, Expect.() -> Unit>, notToBeEmptyAndAllNullable: Fun1, (Expect.() -> Unit)?>, describePrefix: String = "[Atrium] " diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAnyExpectationsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableToHaveNextAndAnyExpectationsSpec.kt similarity index 99% rename from misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAnyExpectationsSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableToHaveNextAndAnyExpectationsSpec.kt index fe89e1144..21b2ec038 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableAnyExpectationsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableToHaveNextAndAnyExpectationsSpec.kt @@ -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, Expect.() -> Unit>, notToBeEmptyAndAnyNullable: Fun1, (Expect.() -> Unit)?>, describePrefix: String = "[Atrium] " diff --git a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableNoneExpectationsSpec.kt b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableToHaveNextAndNoneExpectationsSpec.kt similarity index 99% rename from misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableNoneExpectationsSpec.kt rename to misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableToHaveNextAndNoneExpectationsSpec.kt index 72426e9c0..319128bce 100644 --- a/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableNoneExpectationsSpec.kt +++ b/misc/specs/atrium-specs-common/src/main/kotlin/ch/tutteli/atrium/specs/integration/IterableToHaveNextAndNoneExpectationsSpec.kt @@ -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, Expect.() -> Unit>, notToBeEmptyAndNoneNullable: Fun1, (Expect.() -> Unit)?>, describePrefix: String = "[Atrium] "