diff --git a/README.md b/README.md
index e02ead502f..3f96dc7df8 100644
--- a/README.md
+++ b/README.md
@@ -1167,7 +1167,7 @@ then only failing expectations are shown.
💬 Show only failing expectations/elements earlier than 10 elements?
You can use the `report` option to specify when Atrium shall start to show only failing expectations.
-Following an example changing the limit to 3 elements by using `showOnlyFailingIfMoreElementsThan` :
+Following an example changing the limit to 3 elements by using `showOnlyFailingIfMoreExpectedElementsThan` :
@@ -1176,7 +1176,7 @@ expect(listOf(1, 2, 2, 4)).toContainExactly(
{ toBeLessThan(3) },
{ toBeLessThan(2) },
{ toBeGreaterThan(1) },
- report = { showOnlyFailingIfMoreElementsThan(3) }
+ report = { showOnlyFailingIfMoreExpectedElementsThan(2) }
)
```
↑ [Example](https://github.com/robstoll/atrium/tree/main/misc/tools/readme-examples/src/main/kotlin/readme/examples/MostExamplesSpec.kt#L154) ↓ [Output](#ex-collection-reportOptions-1)
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInAnyOrderOnlyCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInAnyOrderOnlyCreators.kt
index b74f874297..deba1cbb74 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInAnyOrderOnlyCreators.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInAnyOrderOnlyCreators.kt
@@ -10,6 +10,8 @@ import ch.tutteli.atrium.logic.creating.iterable.contains.creators.entriesInAnyO
import ch.tutteli.atrium.logic.creating.iterable.contains.creators.values
import ch.tutteli.atrium.logic.creating.iterable.contains.creators.valuesInAnyOrderOnly
import ch.tutteli.atrium.logic.creating.iterable.contains.searchbehaviours.InAnyOrderOnlySearchBehaviour
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InOrderOnlyReportingOptions
import ch.tutteli.atrium.logic.creating.typeutils.IterableLikeToIterableTransformer
import ch.tutteli.atrium.logic.utils.toVarArg
import ch.tutteli.kbox.glue
@@ -26,7 +28,7 @@ import ch.tutteli.kbox.glue
*
* @since 0.14.0 -- API existed for [Iterable] but not for [IterableLike].
*/
-fun EntryPointStep.value(expected: E): Expect =
+fun EntryPointStep.value(expected: E): Expect =
values(expected)
/**
@@ -36,15 +38,19 @@ fun EntryPointStep.val
*
* @param expected The value which is expected to be contained within the subject (an [IterableLike]).
* @param otherExpected Additional values which are expected to be contained within [IterableLike].
+ * @param report The lambda configuring the [InAnyOrderOnlyReportingOptions] -- it is optional where
+ * the default [InAnyOrderOnlyReportingOptions] apply if not specified.
+ * since 0.18.0
*
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.14.0 -- API existed for [Iterable] but not for [IterableLike].
*/
-fun EntryPointStep.values(
+fun EntryPointStep.values(
expected: E,
- vararg otherExpected: E
-): Expect = _logicAppend { valuesInAnyOrderOnly(expected glue otherExpected) }
+ vararg otherExpected: E,
+ report: InAnyOrderOnlyReportingOptions.() -> Unit = {}
+): Expect = _logicAppend { valuesInAnyOrderOnly(expected glue otherExpected, report) }
/**
* Finishes the specification of the sophisticated `contains` assertion where the subject (an [IterableLike])
@@ -61,7 +67,7 @@ fun EntryPointStep.val
*
* @since 0.14.0 -- API existed for [Iterable] but not for [IterableLike].
*/
-fun EntryPointStep.entry(
+fun EntryPointStep.entry(
assertionCreatorOrNull: (Expect.() -> Unit)?
): Expect = entries(assertionCreatorOrNull)
@@ -85,15 +91,19 @@ fun EntryPointStep EntryPointStep.entries(
+fun EntryPointStep.entries(
assertionCreatorOrNull: (Expect.() -> Unit)?,
- vararg otherAssertionCreatorsOrNulls: (Expect.() -> Unit)?
-): Expect = _logicAppend { entriesInAnyOrderOnly(assertionCreatorOrNull glue otherAssertionCreatorsOrNulls) }
+ vararg otherAssertionCreatorsOrNulls: (Expect.() -> Unit)?,
+ report: InAnyOrderOnlyReportingOptions.() -> Unit = {}
+): Expect = _logicAppend { entriesInAnyOrderOnly(assertionCreatorOrNull glue otherAssertionCreatorsOrNulls, report) }
/**
* Finishes the specification of the sophisticated `contains` assertion where the subject (an [IterableLike])
@@ -106,6 +116,9 @@ fun EntryPointStep EntryPointStep EntryPointStep.elementsOf(
- expectedIterableLike: IterableLike
-): Expect = _logic.toVarArg(expectedIterableLike).let { (first, rest) -> values(first, *rest) }
+inline fun EntryPointStep.elementsOf(
+ expectedIterableLike: IterableLike,
+ noinline report: InAnyOrderOnlyReportingOptions.() -> Unit = {}
+): Expect = _logic.toVarArg(expectedIterableLike).let { (first, rest) -> values(first, *rest, report = report) }
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInOrderOnlyCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInOrderOnlyCreators.kt
index abfca0a5b1..40562400c3 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInOrderOnlyCreators.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInOrderOnlyCreators.kt
@@ -37,6 +37,7 @@ fun EntryPointStep.value
* @param otherExpected Additional values which are expected to be contained within [IterableLike].
* @param report The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
* the default [InOrderOnlyReportingOptions] apply if not specified.
+ * since 0.17.0
*
* @return an [Expect] for the subject of `this` expectation.
*
@@ -81,6 +82,7 @@ fun EntryPointStep EntryPointStep EntryPointStep,
secondGroup: Group,
vararg otherExpectedGroups: Group,
- report: InOrderOnlyReportingOptions.() -> Unit = {}
+ report: InOrderOnlyReportingOptions.() -> Unit = {},
+ reportInGroup: InAnyOrderOnlyReportingOptions.() -> Unit = {}
): Expect = _logicAppend {
- valuesInOrderOnlyGrouped(groupsToList(firstGroup, secondGroup, otherExpectedGroups), report)
+ valuesInOrderOnlyGrouped(groupsToList(firstGroup, secondGroup, otherExpectedGroups), report, reportInGroup)
}
/**
@@ -54,6 +60,10 @@ fun EntryPointStep EntryPointStep.() -> Unit)?>,
secondGroup: Group<(Expect.() -> Unit)?>,
vararg otherExpectedGroups: Group<(Expect.() -> Unit)?>,
- report: InOrderOnlyReportingOptions.() -> Unit = {}
+ report: InOrderOnlyReportingOptions.() -> Unit = {},
+ reportInGroup: InAnyOrderOnlyReportingOptions.() -> Unit = {}
): Expect = _logicAppend {
- entriesInOrderOnlyGrouped(groupsToList(firstGroup, secondGroup, otherExpectedGroups), report)
+ entriesInOrderOnlyGrouped(groupsToList(firstGroup, secondGroup, otherExpectedGroups), report, reportInGroup)
}
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapLikeToContainInOrderOnlyCreators.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapLikeToContainInOrderOnlyCreators.kt
index 49eb84cd34..615e6e892b 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapLikeToContainInOrderOnlyCreators.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/mapLikeToContainInOrderOnlyCreators.kt
@@ -33,6 +33,10 @@ fun EntryPointStep.entr
* Finishes the specification of the sophisticated `contains` assertion where the subject (a [MapLike])
* needs to contain only the given [keyValuePair] as well as the [otherPairs] in the specified order.
*
+ * @param report The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
+ * the default [InOrderOnlyReportingOptions] apply if not specified.
+ * since 0.18.0
+ *
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.15.0
@@ -41,7 +45,7 @@ fun EntryPointStep.entr
keyValuePair: Pair,
vararg otherPairs: Pair,
report: InOrderOnlyReportingOptions.() -> Unit = {}
-): Expect = _logicAppend { keyValuePairsInOrderOnly(keyValuePair glue otherPairs,report) }
+): Expect = _logicAppend { keyValuePairsInOrderOnly(keyValuePair glue otherPairs, report) }
/**
@@ -69,6 +73,10 @@ inline fun EntryPointStep EntryPointStep EntryPointStep.entriesOf(
expectedMapLike: MapLike,
report: InOrderOnlyReportingOptions.() -> Unit = {}
-): Expect = _logic.toVarArgPairs(expectedMapLike).let { (first, rest) -> entries(first, *rest, report = report) }
+): Expect =
+ _logic.toVarArgPairs(expectedMapLike).let { (first, rest) -> entries(first, *rest, report = report) }
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderAtLeast1EntriesExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderAtLeast1EntriesExpectationsSpec.kt
index 2b75c0a8df..8db1736beb 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderAtLeast1EntriesExpectationsSpec.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderAtLeast1EntriesExpectationsSpec.kt
@@ -43,7 +43,6 @@ class IterableToContainInAnyOrderAtLeast1EntriesExpectationsSpec : Spek({
else expect.toContain.inAnyOrder.atLeast(1).entries(a, *aX)
}
-
@Suppress("unused", "UNUSED_VALUE")
private fun ambiguityTest() {
var list: Expect> = notImplemented()
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderExactlyValuesExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderExactlyValuesExpectationsSpec.kt
index b1e5ed5623..7751aa5331 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderExactlyValuesExpectationsSpec.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderExactlyValuesExpectationsSpec.kt
@@ -46,5 +46,4 @@ class IterableToContainInAnyOrderExactlyValuesExpectationsSpec :
subList = subList.toContain.inAnyOrder.exactly(2).values(1, 2.2)
star = star.toContain.inAnyOrder.exactly(2).values(1, 1.2, "asdf")
}
-
}
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyElementsOfExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyElementsOfExpectationsSpec.kt
index 774f28a61f..c0bf7a3053 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyElementsOfExpectationsSpec.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyElementsOfExpectationsSpec.kt
@@ -1,6 +1,8 @@
package ch.tutteli.atrium.api.fluent.en_GB
import ch.tutteli.atrium.creating.Expect
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
+import ch.tutteli.atrium.specs.integration.IterableToContainSpecBase.Companion.emptyInAnyOrderOnlyReportOptions
import ch.tutteli.atrium.specs.notImplemented
import ch.tutteli.atrium.specs.withNullableSuffix
import org.spekframework.spek2.Spek
@@ -15,11 +17,12 @@ class IterableToContainInAnyOrderOnlyElementsOfExpectationsSpec : Spek({
(functionDescription to C::toContainElementsOfNullable).withNullableSuffix()
)
- object BuilderIterableLikeToIterableSpec : ch.tutteli.atrium.specs.integration.IterableLikeToIterableSpec>(
- functionDescription,
- listOf(1, 2),
- { input -> toContain.inAnyOrder.only.elementsOf(input) }
- )
+ object BuilderIterableLikeToIterableSpec :
+ ch.tutteli.atrium.specs.integration.IterableLikeToIterableSpec>(
+ functionDescription,
+ listOf(1, 2),
+ { input -> toContain.inAnyOrder.only.elementsOf(input) }
+ )
companion object : IterableToContainSpecBase() {
val functionDescription = "$toContain.$inAnyOrder.$only.$elementsOf"
@@ -27,17 +30,24 @@ class IterableToContainInAnyOrderOnlyElementsOfExpectationsSpec : Spek({
private fun toContainElementsOf(
expect: Expect>,
a: Double,
- aX: Array
- ): Expect> = expect.toContain.inAnyOrder.only.elementsOf(listOf(a, *aX))
+ aX: Array,
+ report: InAnyOrderOnlyReportingOptions.() -> Unit
+ ): Expect> =
+ if (report == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inAnyOrder.only.elementsOf(listOf(a, *aX))
+ } else expect.toContain.inAnyOrder.only.elementsOf(listOf(a, *aX), report = report)
private fun toContainElementsOfNullable(
expect: Expect>,
a: Double?,
- aX: Array
- ): Expect> = expect.toContain.inAnyOrder.only.elementsOf(sequenceOf(a, *aX))
+ aX: Array,
+ report: InAnyOrderOnlyReportingOptions.() -> Unit
+ ): Expect> =
+ if (report == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inAnyOrder.only.elementsOf(listOf(a, *aX))
+ } else expect.toContain.inAnyOrder.only.elementsOf(listOf(a, *aX), report = report)
}
-
@Suppress("unused", "UNUSED_VALUE")
private fun ambiguityTest() {
var list: Expect> = notImplemented()
@@ -49,5 +59,16 @@ class IterableToContainInAnyOrderOnlyElementsOfExpectationsSpec : Spek({
nList = nList.toContain.inAnyOrder.only.elementsOf(listOf())
subList = subList.toContain.inAnyOrder.only.elementsOf(listOf())
star = star.toContain.inAnyOrder.only.elementsOf(listOf())
+
+ list = list.toContain.inAnyOrder.only.elementsOf(listOf(), report = {})
+ nList = nList.toContain.inAnyOrder.only.elementsOf(listOf(), report = {})
+ subList = subList.toContain.inAnyOrder.only.elementsOf(listOf(), report = {})
+ star = star.toContain.inAnyOrder.only.elementsOf(listOf(), report = {})
+
+ nList = nList.toContain.inAnyOrder.only.elementsOf(listOf())
+ star = star.toContain.inAnyOrder.only.elementsOf(listOf())
+
+ list = list.toContain.inAnyOrder.only.elementsOf(listOf(), report = {})
+ star = star.toContain.inAnyOrder.only.elementsOf(listOf(), report = {})
}
}
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyEntriesExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyEntriesExpectationsSpec.kt
index f3a6b2f58d..62e46d52e6 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyEntriesExpectationsSpec.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyEntriesExpectationsSpec.kt
@@ -1,6 +1,7 @@
package ch.tutteli.atrium.api.fluent.en_GB
import ch.tutteli.atrium.creating.Expect
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
import ch.tutteli.atrium.specs.notImplemented
import ch.tutteli.atrium.specs.withNullableSuffix
@@ -15,21 +16,27 @@ class IterableToContainInAnyOrderOnlyEntriesExpectationsSpec :
private fun toContainInAnyOrderOnlyEntries(
expect: Expect>,
a: Expect.() -> Unit,
- aX: Array.() -> Unit>
+ aX: Array.() -> Unit>,
+ report: InAnyOrderOnlyReportingOptions.() -> Unit
): Expect> =
- if (aX.isEmpty()) expect.toContain.inAnyOrder.only.entry(a)
- else expect.toContain.inAnyOrder.only.entries(a, *aX)
+ if (report === emptyInOrderOnlyReportOptions) {
+ if (aX.isEmpty()) expect.toContain.inAnyOrder.only.entry(a)
+ else expect.toContain.inAnyOrder.only.entries(a, *aX)
+ } else expect.toContain.inAnyOrder.only.entries(a, *aX, report = report)
+
private fun toContainInAnyOrderOnlyNullableEntries(
expect: Expect>,
a: (Expect.() -> Unit)?,
- aX: Array.() -> Unit)?>
+ aX: Array.() -> Unit)?>,
+ report: InAnyOrderOnlyReportingOptions.() -> Unit
): Expect> =
- if (aX.isEmpty()) expect.toContain.inAnyOrder.only.entry(a)
- else expect.toContain.inAnyOrder.only.entries(a, *aX)
+ if (report === emptyInOrderOnlyReportOptions) {
+ if (aX.isEmpty()) expect.toContain.inAnyOrder.only.entry(a)
+ else expect.toContain.inAnyOrder.only.entries(a, *aX)
+ } else expect.toContain.inAnyOrder.only.entries(a, *aX, report = report)
}
-
@Suppress("unused", "UNUSED_VALUE")
private fun ambiguityTest() {
var list: Expect> = notImplemented()
@@ -50,7 +57,15 @@ class IterableToContainInAnyOrderOnlyEntriesExpectationsSpec :
subList = subList.toContain.inAnyOrder.only.entries({}, {})
star = star.toContain.inAnyOrder.only.entries({}, {})
+ list = list.toContain.inAnyOrder.only.entries({}, {}, report = {})
+ nList = nList.toContain.inAnyOrder.only.entries({}, {}, report = {})
+ subList = subList.toContain.inAnyOrder.only.entries({}, {}, report = {})
+ star = star.toContain.inAnyOrder.only.entries({}, {}, report = {})
+
nList = nList.toContain.inAnyOrder.only.entries(null, {}, null)
star = star.toContain.inAnyOrder.only.entries(null, {}, null)
+
+ nList = nList.toContain.inAnyOrder.only.entries(null, {}, null, report = {})
+ star = star.toContain.inAnyOrder.only.entries(null, {}, null, report = {})
}
}
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyValuesExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyValuesExpectationsSpec.kt
index d87c0c7cc7..326343cbff 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyValuesExpectationsSpec.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInAnyOrderOnlyValuesExpectationsSpec.kt
@@ -1,6 +1,7 @@
package ch.tutteli.atrium.api.fluent.en_GB
import ch.tutteli.atrium.creating.Expect
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
import ch.tutteli.atrium.specs.notImplemented
import ch.tutteli.atrium.specs.withNullableSuffix
@@ -15,18 +16,24 @@ class IterableToContainInAnyOrderOnlyValuesExpectationsSpec :
private fun toContainInAnyOrderOnlyValues(
expect: Expect>,
a: Double,
- aX: Array
+ aX: Array,
+ report: InAnyOrderOnlyReportingOptions.() -> Unit
): Expect> =
- if (aX.isEmpty()) expect.toContain.inAnyOrder.only.value(a)
- else expect.toContain.inAnyOrder.only.values(a, *aX)
+ if (report === emptyInOrderOnlyReportOptions) {
+ if (aX.isEmpty()) expect.toContain.inAnyOrder.only.value(a)
+ else expect.toContain.inAnyOrder.only.values(a, *aX)
+ } else expect.toContain.inAnyOrder.only.values(a, *aX, report = report)
private fun toContainInAnyOrderOnlyNullableValues(
expect: Expect>,
a: Double?,
- aX: Array
+ aX: Array,
+ report: InAnyOrderOnlyReportingOptions.() -> Unit
): Expect> =
- if (aX.isEmpty()) expect.toContain.inAnyOrder.only.value(a)
- else expect.toContain.inAnyOrder.only.values(a, *aX)
+ if (report === emptyInOrderOnlyReportOptions) {
+ if (aX.isEmpty()) expect.toContain.inAnyOrder.only.value(a)
+ else expect.toContain.inAnyOrder.only.values(a, *aX)
+ } else expect.toContain.inAnyOrder.only.values(a, *aX, report = report)
}
@Suppress("unused", "UNUSED_VALUE")
@@ -45,5 +52,16 @@ class IterableToContainInAnyOrderOnlyValuesExpectationsSpec :
nList = nList.toContain.inAnyOrder.only.values(1, 1.2)
subList = subList.toContain.inAnyOrder.only.values(1, 2.2)
star = star.toContain.inAnyOrder.only.values(1, 1.2, "asdf")
+
+ list = list.toContain.inAnyOrder.only.values(1, 1.2, report = {})
+ nList = nList.toContain.inAnyOrder.only.values(1, 1.2, report = {})
+ subList = subList.toContain.inAnyOrder.only.values(1, 2.2, report = {})
+ star = star.toContain.inAnyOrder.only.values(1, 1.2, "asdf", report = {})
+
+ nList = nList.toContain.inAnyOrder.only.values(null, 1.2)
+ star = star.toContain.inAnyOrder.only.values(null, 1.2, "asdf")
+
+ nList = nList.toContain.inAnyOrder.only.values(null, 1.2, report = {})
+ star = star.toContain.inAnyOrder.only.values(null, 1.2, "asdf", report = {})
}
}
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyEntriesExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyEntriesExpectationsSpec.kt
index e9e5eb585f..a4585dd144 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyEntriesExpectationsSpec.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyEntriesExpectationsSpec.kt
@@ -114,7 +114,7 @@ class IterableToContainInOrderOnlyEntriesExpectationsSpec : Spek({
subList = subList.toContainExactly({}, {})
star = star.toContainExactly({}, {})
- list = list.toContainExactly({}, {}, report = { showOnlyFailingIfMoreElementsThan(20) })
+ list = list.toContainExactly({}, {}, report = { showOnlyFailingIfMoreExpectedElementsThan(20) })
nList = nList.toContainExactly({}, {}, report = { showOnlyFailing() })
subList = subList.toContainExactly({}, {}, report = { showAlwaysSummary() })
star = star.toContainExactly({}, {}, report = { })
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec.kt
index 6d4ccb8d92..278aeb997e 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec.kt
@@ -1,6 +1,8 @@
package ch.tutteli.atrium.api.fluent.en_GB
import ch.tutteli.atrium.creating.Expect
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InOrderOnlyReportingOptions
import ch.tutteli.atrium.logic.utils.Group
import ch.tutteli.atrium.specs.notImplemented
@@ -17,8 +19,26 @@ class IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec :
expect: Expect>,
a1: Group<(Expect.() -> Unit)?>,
a2: Group<(Expect.() -> Unit)?>,
- aX: Array.() -> Unit)?>>
- ): Expect> = expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX)
+ aX: Array.() -> Unit)?>>,
+ report: InOrderOnlyReportingOptions.() -> Unit,
+ reportInGroup: InAnyOrderOnlyReportingOptions.() -> Unit
+ ): Expect> =
+ if (report === emptyInOrderOnlyReportOptions && reportInGroup == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX)
+ } else if (reportInGroup == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX, report = report)
+ } else if (report == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX, reportInGroup = reportInGroup)
+ } else {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(
+ a1,
+ a2,
+ *aX,
+ report = report,
+ reportInGroup = reportInGroup
+ )
+ }
+
private fun groupFactory(groups: Array.() -> Unit)?>) =
when (groups.size) {
@@ -47,7 +67,47 @@ class IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec :
nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(Entry {}, Entries({}, {}), report = {})
subList = subList.toContain.inOrder.only.grouped.within.inAnyOrder(Entry {}, Entries({}, {}), report = {})
//TODO check if is still necessary with kotlin 1.4, if so, report a bug
- star = star.toContain.inOrder.only.grouped.within.inAnyOrder(Entry {}, Entries({}, {}))
+ star = star.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry {},
+ Entries({}, {}),
+ report = {}
+ )
+
+ list = list.toContain.inOrder.only.grouped.within.inAnyOrder(Entry {}, Entries({}, {}), reportInGroup = {})
+ nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(Entry {}, Entries({}, {}), reportInGroup = {})
+ subList = subList.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry {}, Entries({}, {}), reportInGroup = {})
+ //TODO check if is still necessary with kotlin 1.4, if so, report a bug
+ star = star.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry {},
+ Entries({}, {}),
+ reportInGroup = {}
+ )
+
+ list = list.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry {},
+ Entries({}, {}),
+ report = {},
+ reportInGroup = {}
+ )
+ nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry {},
+ Entries({}, {}),
+ report = {},
+ reportInGroup = {}
+ )
+ subList = subList.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry {},
+ Entries({}, {}),
+ report = {},
+ reportInGroup = {}
+ )
+ star = star.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry {},
+ Entries({}, {}),
+ report = {},
+ reportInGroup = {}
+ )
nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(Entry(null), Entries({}, null))
//TODO check if is still necessary with kotlin 1.4, if so, report a bug
@@ -55,6 +115,32 @@ class IterableToContainInOrderOnlyGroupedEntriesExpectationsSpec :
nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(Entry(null), Entries({}, null), report = {})
//TODO check if is still necessary with kotlin 1.4, if so, report a bug
- star = star.toContain.inOrder.only.grouped.within.inAnyOrder(Entry(null), Entries(null, {}))
+ star = star.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry(null),
+ Entries(null, {}),
+ report = {})
+
+ nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry(null),
+ Entries({}, null),
+ reportInGroup = {}
+ )
+ //TODO check if is still necessary with kotlin 1.4, if so, report a bug
+ star = star.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry(null),
+ Entries(null, {}),
+ reportInGroup = {})
+
+ nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry(null),
+ Entries({}, null),
+ report = {},
+ reportInGroup = {})
+ //TODO check if is still necessary with kotlin 1.4, if so, report a bug
+ star = star.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Entry(null),
+ Entries(null, {}),
+ report = {},
+ reportInGroup = {})
}
}
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyGroupedValuesExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyGroupedValuesExpectationsSpec.kt
index 4dc5cd3f15..a39353686f 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyGroupedValuesExpectationsSpec.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyGroupedValuesExpectationsSpec.kt
@@ -1,6 +1,8 @@
package ch.tutteli.atrium.api.fluent.en_GB
import ch.tutteli.atrium.creating.Expect
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InOrderOnlyReportingOptions
import ch.tutteli.atrium.logic.utils.Group
import ch.tutteli.atrium.specs.notImplemented
import ch.tutteli.atrium.specs.withNullableSuffix
@@ -14,14 +16,32 @@ class IterableToContainInOrderOnlyGroupedValuesExpectationsSpec :
"[Atrium][Builder] "
) {
companion object : IterableToContainSpecBase() {
- val functionDescription = "$toContain.$inOrder.$only.$grouped.$within.$withinInAnyOrder"
+ val functionDescription = "$toContain.$inOrder.$only.$grouped.$within.$withinInAnyOrder"
private fun toContainInOrderOnlyGroupedInAnyOrderValues(
expect: Expect>,
a1: Group,
a2: Group,
- aX: Array>
- ): Expect> = expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX)
+ aX: Array>,
+ report: InOrderOnlyReportingOptions.() -> Unit,
+ reportInGroup: InAnyOrderOnlyReportingOptions.() -> Unit
+ ): Expect> =
+ if (report === emptyInOrderOnlyReportOptions && reportInGroup == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX)
+ } else if (reportInGroup == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX, report = report)
+ } else if (report == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX, reportInGroup = reportInGroup)
+ } else {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(
+ a1,
+ a2,
+ *aX,
+ report = report,
+ reportInGroup = reportInGroup
+ )
+ }
+
private fun groupFactory(groups: Array): Group =
when (groups.size) {
@@ -36,8 +56,25 @@ class IterableToContainInOrderOnlyGroupedValuesExpectationsSpec :
expect: Expect>,
a1: Group,
a2: Group,
- aX: Array>
- ): Expect> = expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX)
+ aX: Array>,
+ report: InOrderOnlyReportingOptions.() -> Unit,
+ reportInGroup: InAnyOrderOnlyReportingOptions.() -> Unit
+ ): Expect> =
+ if (report === emptyInOrderOnlyReportOptions && reportInGroup == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX)
+ } else if (reportInGroup == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX, report = report)
+ } else if (report == emptyInAnyOrderOnlyReportOptions) {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(a1, a2, *aX, reportInGroup = reportInGroup)
+ } else {
+ expect.toContain.inOrder.only.grouped.within.inAnyOrder(
+ a1,
+ a2,
+ *aX,
+ report = report,
+ reportInGroup = reportInGroup
+ )
+ }
private fun nullableGroupFactory(groups: Array): Group =
when (groups.size) {
@@ -66,10 +103,50 @@ class IterableToContainInOrderOnlyGroupedValuesExpectationsSpec :
subList = subList.toContain.inOrder.only.grouped.within.inAnyOrder(Value(1), Values(1, 2), report = {})
star = star.toContain.inOrder.only.grouped.within.inAnyOrder(Value(1), Values(1, 2), report = {})
+ list = list.toContain.inOrder.only.grouped.within.inAnyOrder(Value(1), Values(1, 2), reportInGroup = {})
+ nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(Value(1), Values(1, 2), reportInGroup = {})
+ subList = subList.toContain.inOrder.only.grouped.within.inAnyOrder(Value(1), Values(1, 2), reportInGroup = {})
+ star = star.toContain.inOrder.only.grouped.within.inAnyOrder(Value(1), Values(1, 2), reportInGroup = {})
+
+ list = list.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Value(1),
+ Values(1, 2),
+ report = {},
+ reportInGroup = {})
+ nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Value(1),
+ Values(1, 2),
+ report = {},
+ reportInGroup = {})
+ subList = subList.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Value(1),
+ Values(1, 2),
+ report = {},
+ reportInGroup = {})
+ star = star.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Value(1),
+ Values(1, 2),
+ report = {},
+ reportInGroup = {})
+
nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(Value(null), Values(1, null))
star = star.toContain.inOrder.only.grouped.within.inAnyOrder(Value(null), Values(null, 2))
nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(Value(null), Values(1, null), report = {})
star = star.toContain.inOrder.only.grouped.within.inAnyOrder(Value(null), Values(null, 2), report = {})
+
+ nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(Value(null), Values(1, null), reportInGroup = {})
+ star = star.toContain.inOrder.only.grouped.within.inAnyOrder(Value(null), Values(null, 2), reportInGroup = {})
+
+ nList = nList.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Value(null),
+ Values(1, null),
+ report = {},
+ reportInGroup = {})
+ star = star.toContain.inOrder.only.grouped.within.inAnyOrder(
+ Value(null),
+ Values(null, 2),
+ report = {},
+ reportInGroup = {})
}
}
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyValuesExpectationsSpec.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyValuesExpectationsSpec.kt
index 1b1b52c1a6..86b3093c4b 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyValuesExpectationsSpec.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyValuesExpectationsSpec.kt
@@ -78,13 +78,18 @@ class IterableToContainInOrderOnlyValuesExpectationsSpec : Spek({
subList = subList.toContain.inOrder.only.values(1, 2.2, report = {})
star = star.toContain.inOrder.only.values(1, 1.2, "asdf", report = {})
+ nList = nList.toContain.inOrder.only.values(null, 1.2)
+ star = star.toContain.inOrder.only.values(null, 1.2, "asdf")
+
+ nList = nList.toContain.inOrder.only.values(null, 1.2, report = {})
+ star = star.toContain.inOrder.only.values(null, 1.2, "asdf", report = {})
list = list.toContainExactly(1)
nList = nList.toContainExactly(1, 1.2)
subList = subList.toContainExactly(1)
star = star.toContainExactly(1, "a", null)
- list = list.toContainExactly(1, report = { showOnlyFailingIfMoreElementsThan(1) })
+ list = list.toContainExactly(1, report = { showOnlyFailingIfMoreExpectedElementsThan(1) })
nList = nList.toContainExactly(1, 1.2, report = { showOnlyFailing() })
subList = subList.toContainExactly(1, 2.2, report = { showAlwaysSummary() })
// TODO would wish this does not work, maybe @OnlyInputTypes would help?
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainSpecBase.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainSpecBase.kt
index c2adfa6b7c..e331e72da5 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainSpecBase.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainSpecBase.kt
@@ -5,8 +5,9 @@ import ch.tutteli.atrium.logic.utils.Group
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
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InOrderOnlyReportingOptions
-import kotlin.reflect.KFunction5
+import kotlin.reflect.KFunction6
import kotlin.reflect.KProperty
abstract class IterableToContainSpecBase {
@@ -32,8 +33,8 @@ abstract class IterableToContainSpecBase {
protected val only = IterableLikeContains.EntryPointStep, InAnyOrderSearchBehaviour>::only.name
protected val grouped = IterableLikeContains.EntryPointStep, InOrderOnlySearchBehaviour>::grouped.name
protected val within = IterableLikeContains.EntryPointStep, InOrderOnlyGroupedSearchBehaviour>::within.name
- private val withinInAnyOrderFun: KFunction5, InOrderOnlyGroupedWithinSearchBehaviour>, Group, Group, Array>, InOrderOnlyReportingOptions.() -> Unit, Expect>> =
- IterableLikeContains.EntryPointStep, InOrderOnlyGroupedWithinSearchBehaviour, >::inAnyOrder
+ private val withinInAnyOrderFun: KFunction6, InOrderOnlyGroupedWithinSearchBehaviour>, Group, Group, Array>, InOrderOnlyReportingOptions.() -> Unit, InAnyOrderOnlyReportingOptions.() -> Unit, Expect>> =
+ IterableLikeContains.EntryPointStep, InOrderOnlyGroupedWithinSearchBehaviour>::inAnyOrder
protected val withinInAnyOrder = withinInAnyOrderFun.name
//@formatter:on
}
diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/IterableExpectationSamples.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/IterableExpectationSamples.kt
index 523ab49ec8..29f81c7b32 100644
--- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/IterableExpectationSamples.kt
+++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/IterableExpectationSamples.kt
@@ -94,7 +94,7 @@ class IterableExpectationSamples {
// optional
report = { // allows configuring reporting, e.g.
showOnlyFailing() // would not show the successful `B`
- showOnlyFailingIfMoreElementsThan(10)
+ showOnlyFailingIfMoreExpectedElementsThan(10)
}
)
}
@@ -142,7 +142,7 @@ class IterableExpectationSamples {
// optional
report = { // allows configuring reporting, e.g.
showOnlyFailing() // would not show the successful `toBeLessThan(11)`
- showOnlyFailingIfMoreElementsThan(10)
+ showOnlyFailingIfMoreExpectedElementsThan(10)
}
)
}
@@ -166,7 +166,7 @@ class IterableExpectationSamples {
// optional
report = { // allows configuring reporting, e.g.
showOnlyFailing() // would not show the successful first and second `1, 2`
- showOnlyFailingIfMoreElementsThan(10)
+ showOnlyFailingIfMoreExpectedElementsThan(10)
}
)
}
diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/WithInAnyOrderOnlyReportingOptions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/WithInAnyOrderOnlyReportingOptions.kt
new file mode 100644
index 0000000000..2c1b7ac2bf
--- /dev/null
+++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/WithInAnyOrderOnlyReportingOptions.kt
@@ -0,0 +1,10 @@
+package ch.tutteli.atrium.api.infix.en_GB.creating.iterable
+
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
+
+/**
+ * Parameter object to wrap a given [T] next to specifying [InAnyOrderOnlyReportingOptions].
+ *
+ * @since 0.18.0
+ */
+data class WithInAnyOrderOnlyReportingOptions(val options: InAnyOrderOnlyReportingOptions.() -> Unit, val t: T)
diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/WithInOrderOnlyReportingOptions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/WithInOrderOnlyReportingOptions.kt
index 069c4aa39c..47ad11455f 100644
--- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/WithInOrderOnlyReportingOptions.kt
+++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/creating/iterable/WithInOrderOnlyReportingOptions.kt
@@ -7,4 +7,4 @@ import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InOrderO
*
* @since 0.18.0
*/
-data class WithInOrderOnlyReportingOptions(val report: InOrderOnlyReportingOptions.() -> Unit, val t: T)
+data class WithInOrderOnlyReportingOptions(val options: InOrderOnlyReportingOptions.() -> Unit, val t: T)
diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/helperFunctions.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/helperFunctions.kt
index e6eb2b37d2..d9ed69a1dd 100644
--- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/helperFunctions.kt
+++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/helperFunctions.kt
@@ -1,11 +1,13 @@
package ch.tutteli.atrium.api.infix.en_GB
import ch.tutteli.atrium.api.infix.en_GB.creating.*
+import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.WithInAnyOrderOnlyReportingOptions
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.WithInOrderOnlyReportingOptions
import ch.tutteli.atrium.api.infix.en_GB.creating.map.KeyValues
import ch.tutteli.atrium.api.infix.en_GB.creating.map.KeyWithValueCreator
import ch.tutteli.atrium.assertions.Assertion
import ch.tutteli.atrium.creating.Expect
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InOrderOnlyReportingOptions
import ch.tutteli.atrium.logic.creating.typeutils.IterableLike
import ch.tutteli.atrium.logic.creating.typeutils.MapLike
@@ -20,10 +22,10 @@ fun all(t: T, vararg ts: T): All = All(t, ts)
/**
* Helper function to create a [WithInOrderOnlyReportingOptions] wrapping an [IterableLike]
- * based on the given [iterableLike] and the given [report]-configuration-lambda.
+ * based on the given [iterableLike] and the given [reportOptionsInOrderOnly]-configuration-lambda.
*
* @param iterableLike The [IterableLike] whose elements this function is referring to.
- * @param report The lambda configuring the [InOrderOnlyReportingOptions].
+ * @param reportOptionsInOrderOnly The lambda configuring the [InOrderOnlyReportingOptions].
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.IterableExpectationSamples.toContainExactlyElementsOf
*
@@ -31,8 +33,22 @@ fun all(t: T, vararg ts: T): All = All(t, ts)
*/
fun elementsOf(
iterableLike: T,
- report: InOrderOnlyReportingOptions.() -> Unit
-): WithInOrderOnlyReportingOptions = WithInOrderOnlyReportingOptions(report, iterableLike)
+ reportOptionsInOrderOnly: InOrderOnlyReportingOptions.() -> Unit
+): WithInOrderOnlyReportingOptions = WithInOrderOnlyReportingOptions(reportOptionsInOrderOnly, iterableLike)
+
+/**
+ * Helper function to create a [WithInAnyOrderOnlyReportingOptions] wrapping an [IterableLike]
+ * based on the given [iterableLike] and the given [reportOptionsInAnyOrderOnly]-configuration-lambda.
+ *
+ * @param iterableLike The [IterableLike] whose elements this function is referring to.
+ * @param reportOptionsInAnyOrderOnly The lambda configuring the [InAnyOrderOnlyReportingOptions].
+ *
+ * @since 0.18.0
+ */
+fun elementsOf(
+ iterableLike: T,
+ reportOptionsInAnyOrderOnly: InAnyOrderOnlyReportingOptions.() -> Unit
+): WithInAnyOrderOnlyReportingOptions = WithInAnyOrderOnlyReportingOptions(reportOptionsInAnyOrderOnly, iterableLike)
/**
* Helper function to create an [Entry] based on the given [assertionCreatorOrNull].
@@ -60,8 +76,8 @@ fun entries(
/**
* Helper function to create a [WithInOrderOnlyReportingOptions] wrapping an [Entries] based on the given
- * [assertionCreatorOrNull] and [otherAssertionCreatorsOrNulls] as well as the given [report]-configuration-lambda
- * -- allows expressing `{ }, vararg { }, report = { ... }`.
+ * [assertionCreatorOrNull] and [otherAssertionCreatorsOrNulls] as well as the given
+ * [reportOptionsInOrderOnly]-configuration-lambda -- allows expressing `{ }, vararg { }, reportOptionsInOrderOnly = { ... }`.
*
* In case `null` is used for an identification lambda then it is expected that the corresponding entry
* is `null` as well.
@@ -70,7 +86,7 @@ fun entries(
* to be identified if it holds all [Assertion]s the lambda creates.
* In case it is defined as `null`, then an entry is identified if it is `null` as well.
* @param otherAssertionCreatorsOrNulls A variable amount of additional identification lambdas or `null`s.
- * @param report The lambda configuring the [InOrderOnlyReportingOptions].
+ * @param reportOptionsInOrderOnly The lambda configuring the [InOrderOnlyReportingOptions].
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.IterableExpectationSamples.toContainExactlyAssertions
*
@@ -79,23 +95,46 @@ fun entries(
fun entries(
assertionCreatorOrNull: (Expect.() -> Unit)?,
vararg otherAssertionCreatorsOrNulls: (Expect.() -> Unit)?,
- report: InOrderOnlyReportingOptions.() -> Unit
+ reportOptionsInOrderOnly: InOrderOnlyReportingOptions.() -> Unit
): WithInOrderOnlyReportingOptions> =
- WithInOrderOnlyReportingOptions(report, Entries(assertionCreatorOrNull, otherAssertionCreatorsOrNulls))
+ WithInOrderOnlyReportingOptions(reportOptionsInOrderOnly, Entries(assertionCreatorOrNull, otherAssertionCreatorsOrNulls))
+
+/**
+ * Helper function to create a [WithInAnyOrderOnlyReportingOptions] wrapping an [Entries] based on the given
+ * [assertionCreatorOrNull] and [otherAssertionCreatorsOrNulls] as well as the given
+ * [reportOptionsInAnyOrderOnly]-configuration-lambda -- allows expressing `{ }, vararg { }, reportOptionsInAnyOrderOnly = { ... }`.
+ *
+ * In case `null` is used for an identification lambda then it is expected that the corresponding entry
+ * is `null` as well.
+ *
+ * @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered
+ * to be identified if it holds all [Assertion]s the lambda creates.
+ * In case it is defined as `null`, then an entry is identified if it is `null` as well.
+ * @param otherAssertionCreatorsOrNulls A variable amount of additional identification lambdas or `null`s.
+ * @param reportOptionsInAnyOrderOnly The lambda configuring the [InOrderOnlyReportingOptions].
+ *
+ * @since 0.18.0
+ */
+fun entries(
+ assertionCreatorOrNull: (Expect.() -> Unit)?,
+ vararg otherAssertionCreatorsOrNulls: (Expect.() -> Unit)?,
+ reportOptionsInAnyOrderOnly: InAnyOrderOnlyReportingOptions.() -> Unit
+): WithInAnyOrderOnlyReportingOptions> =
+ WithInAnyOrderOnlyReportingOptions(reportOptionsInAnyOrderOnly, Entries(assertionCreatorOrNull, otherAssertionCreatorsOrNulls))
/**
* Helper function to create a [WithInOrderOnlyReportingOptions] wrapping an [MapLike]
- * based on the given [mapLike] and the given [report]-configuration-lambda.
+ * based on the given [mapLike] and the given [reportOptionsInOrderOnly]-configuration-lambda.
*
* @param mapLike The [MapLike] whose elements this function is referring to.
- * @param report The lambda configuring the [InOrderOnlyReportingOptions].
+ * @param reportOptionsInOrderOnly The lambda configuring the [InOrderOnlyReportingOptions].
*
* @since 0.18.0
*/
fun entriesOf(
mapLike: T,
- report: InOrderOnlyReportingOptions.() -> Unit
-): WithInOrderOnlyReportingOptions = WithInOrderOnlyReportingOptions(report, mapLike)
+ reportOptionsInOrderOnly: InOrderOnlyReportingOptions.() -> Unit
+): WithInOrderOnlyReportingOptions = WithInOrderOnlyReportingOptions(reportOptionsInOrderOnly, mapLike)
/**
* Helper function to create a [KeyValues] based on the given [keyValue] and [otherKeyValues]
@@ -113,15 +152,19 @@ fun keyValues(
/**
* Helper function to create a [KeyValues] based on the given [keyValue] and [otherKeyValues]
* -- allows expressing `Pair.() -> Unit)?>, vararg Pair.() -> Unit)?>`.
+ *
+ * @param reportOptionsInOrderOnly The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
+ * the default [InOrderOnlyReportingOptions] apply if not specified.
+ * since 0.18.0
*/
// TODO 1.0.0: consider to rename to entries once updated to Kotlin 1.4 maybe the type inference is better and there
// is no longer a clash with Iterable entries
fun keyValues(
keyValue: KeyWithValueCreator,
vararg otherKeyValues: KeyWithValueCreator,
- report: InOrderOnlyReportingOptions.() -> Unit
+ reportOptionsInOrderOnly: InOrderOnlyReportingOptions.() -> Unit
): WithInOrderOnlyReportingOptions> =
- WithInOrderOnlyReportingOptions(report, KeyValues(keyValue, otherKeyValues))
+ WithInOrderOnlyReportingOptions(reportOptionsInOrderOnly, KeyValues(keyValue, otherKeyValues))
/**
* Helper function to create a [KeyWithValueCreator] based on the given [key] and [valueAssertionCreatorOrNull]
@@ -152,8 +195,8 @@ fun pairs(pair: Pair, vararg otherPairs: Pair): Pairs =
fun pairs(
pair: Pair,
vararg otherPairs: Pair,
- report: InOrderOnlyReportingOptions.() -> Unit
-): WithInOrderOnlyReportingOptions> = WithInOrderOnlyReportingOptions(report, Pairs(pair, otherPairs))
+ reportOptionsInOrderOnly: InOrderOnlyReportingOptions.() -> Unit
+): WithInOrderOnlyReportingOptions> = WithInOrderOnlyReportingOptions(reportOptionsInOrderOnly, Pairs(pair, otherPairs))
/**
* Helper function to create a [PresentWithCreator] based on the given [assertionCreator].
@@ -198,16 +241,34 @@ fun values(value: T, vararg otherValues: T): Values = Values(value, other
/**
* Helper function to create a [WithInOrderOnlyReportingOptions] wrapping a [Values] based on the given
- * [value] and [otherValues] as well as the given [report]-configuration-lambda -- allows expressing
- * `T, vararg T, report = { ... }`.
+ * [value] and [otherValues] as well as the given [reportOptionsInOrderOnly]-configuration-lambda -- allows expressing
+ * `T, vararg T, reportOptionsInOrderOnly = { ... }`.
*
* @param value The first expected value.
* @param otherValues The other expected values in the given order.
- * @param report The lambda configuring the [InOrderOnlyReportingOptions].
+ * @param reportOptionsInOrderOnly The lambda configuring the [InOrderOnlyReportingOptions].
+ *
+ * @since 0.18.0
+ */
+fun values(
+ value: T,
+ vararg otherValues: T,
+ reportOptionsInOrderOnly: InOrderOnlyReportingOptions.() -> Unit
+): WithInOrderOnlyReportingOptions> = WithInOrderOnlyReportingOptions(reportOptionsInOrderOnly, Values(value, otherValues))
+
+/**
+ * Helper function to create a [WithInOrderOnlyReportingOptions] wrapping a [Values] based on the given
+ * [value] and [otherValues] as well as the given [reportOptionsInAnyOrderOnly]-configuration-lambda -- allows expressing
+ * `T, vararg T, reportOptionsInAnyOrderOnly = { ... }`.
+ *
+ * @param value The first expected value.
+ * @param otherValues The other expected values in the given order.
+ * @param reportOptionsInAnyOrderOnly The lambda configuring the [InOrderOnlyReportingOptions].
+ *
* @since 0.18.0
*/
fun values(
value: T,
vararg otherValues: T,
- report: InOrderOnlyReportingOptions.() -> Unit
-): WithInOrderOnlyReportingOptions> = WithInOrderOnlyReportingOptions(report, Values(value, otherValues))
+ reportOptionsInAnyOrderOnly: InAnyOrderOnlyReportingOptions.() -> Unit
+): WithInAnyOrderOnlyReportingOptions> = WithInAnyOrderOnlyReportingOptions(reportOptionsInAnyOrderOnly, Values(value, otherValues))
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
index ce03810e01..369a26f387 100644
--- 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
@@ -164,10 +164,10 @@ infix fun > Expect.toContainExactly(values: Values): Ex
* 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(..., report = {... })`
+ * It is a shortcut for `toContain o inGiven order and only the values(..., reportOptionsInOrderOnly = {... })`
*
* @param values The values which are expected to be contained within the [IterableLike] plus a lambda configuring
- * the [InOrderOnlyReportingOptions] -- use the function `values(t, ..., report = { ... })`
+ * the [InOrderOnlyReportingOptions] -- use the function `values(t, ..., reportOptionsInOrderOnly = { ... })`
* to create a [WithInOrderOnlyReportingOptions] with a wrapped [Values].
*
* @return an [Expect] for the subject of `this` expectation.
@@ -231,10 +231,10 @@ infix fun > Expect.toContainExactly(entries: Entrie
* [entries].t.[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(..., report = { ... })`
+ * It is a shortcut for `toContain o inGiven order and only the entries(..., reportOptionsInOrderOnly = { ... })`
*
* @param entries The entries which are expected to be contained within the [Iterable] plus a lambda configuring
- * the [InOrderOnlyReportingOptions] -- use the function `entries(t, ..., report = { ... })`
+ * the [InOrderOnlyReportingOptions] -- use the function `entries(t, ..., reportOptionsInOrderOnly = { ... })`
* to create a [WithInOrderOnlyReportingOptions] with a wrapped [Entries].
*
* @return an [Expect] for the subject of `this` expectation.
@@ -278,11 +278,11 @@ inline infix fun > Expect.toContainExactlyElements
* [entries].t.[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 elementsOf(..., report = { ... })`
+ * It is a shortcut for `toContain o inGiven order and only the elementsOf(..., reportOptionsInOrderOnly = { ... })`
*
* @param elementsOf The [IterableLike] whose elements are expected to be contained within
* this [IterableLike] plus a lambda configuring the [InOrderOnlyReportingOptions] -- use the function
- * `elementsOf(iterableLike, report = { ... })`
+ * `elementsOf(iterableLike, reportOptionsInOrderOnly = { ... })`
* to create a [WithInOrderOnlyReportingOptions] with a wrapped [IterableLike].
*
* @return an [Expect] for the subject of `this` expectation.
diff --git a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableLikeToContainInAnyOrderOnlyCreators.kt b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableLikeToContainInAnyOrderOnlyCreators.kt
index 7ef4c08f74..7d4a1df94d 100644
--- a/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableLikeToContainInAnyOrderOnlyCreators.kt
+++ b/apis/infix-en_GB/atrium-api-infix-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/infix/en_GB/iterableLikeToContainInAnyOrderOnlyCreators.kt
@@ -2,6 +2,8 @@ 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.api.infix.en_GB.creating.iterable.WithInAnyOrderOnlyReportingOptions
+import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.WithInOrderOnlyReportingOptions
import ch.tutteli.atrium.creating.Expect
import ch.tutteli.atrium.logic._logic
import ch.tutteli.atrium.logic._logicAppend
@@ -10,9 +12,12 @@ import ch.tutteli.atrium.logic.creating.iterable.contains.creators.entriesInAnyO
import ch.tutteli.atrium.logic.creating.iterable.contains.creators.values
import ch.tutteli.atrium.logic.creating.iterable.contains.creators.valuesInAnyOrderOnly
import ch.tutteli.atrium.logic.creating.iterable.contains.searchbehaviours.InAnyOrderOnlySearchBehaviour
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InAnyOrderOnlyReportingOptions
+import ch.tutteli.atrium.logic.creating.iterablelike.contains.reporting.InOrderOnlyReportingOptions
import ch.tutteli.atrium.logic.creating.typeutils.IterableLike
import ch.tutteli.atrium.logic.creating.typeutils.IterableLikeToIterableTransformer
import ch.tutteli.atrium.logic.utils.toVarArg
+import kotlin.jvm.JvmName
/**
* Finishes the specification of the sophisticated `contains` assertion where the subject (an [IterableLike])
@@ -38,7 +43,23 @@ infix fun EntryPointStep EntryPointStep.the(values: Values): Expect =
- _logicAppend { valuesInAnyOrderOnly(values.toList()) }
+ the(WithInAnyOrderOnlyReportingOptions({}, values))
+
+/**
+ * Finishes the specification of the sophisticated `contains` assertion where the subject (an [IterableLike])
+ * needs to contain only the expected [values] where it does not matter in which order.
+ *
+ * @param values The values which are expected to be contained within the [IterableLike] plus a lambda configuring
+ * the [InAnyOrderOnlyReportingOptions] -- use the function `values(t, ..., reportOptionsInAnyOrderOnly = { ... })`
+ * to create a [WithInAnyOrderOnlyReportingOptions] with a wrapped [Values].
+ *
+ * @return an [Expect] for the subject of `this` expectation.
+ *
+ * @since 0.18.0
+ */
+@JvmName("theValuesWithReportingOptions")
+infix fun EntryPointStep.the(values: WithInAnyOrderOnlyReportingOptions>): Expect =
+ _logicAppend { valuesInAnyOrderOnly(values.t.toList(), values.options) }
/**
* Finishes the specification of the sophisticated `contains` assertion where the subject (an [IterableLike])
@@ -76,10 +97,36 @@ infix fun EntryPointStep EntryPointStep.the(
entries: Entries
-): Expect = _logicAppend { entriesInAnyOrderOnly(entries.toList()) }
+): Expect = the(WithInAnyOrderOnlyReportingOptions({}, entries))
+
+/**
+ * Finishes the specification of the sophisticated `contains` assertion where the subject (an [IterableLike])
+ * needs to contain only the given [entries] where it does not matter in which order they appear -- an entry
+ * is contained if it either holds all assertions
+ * [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] creates or it needs to be `null` in case
+ * [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] is defined as `null`
+ *
+ * Notice, that a first-wins strategy applies which means your assertion creator lambdas -- which kind of serve as
+ * identification lambdas -- should be ordered in such a way that the most specific identification lambda appears
+ * first, not that a less specific lambda wins. For instance, given a `setOf(1, 2)` you should not search for
+ * `entries({ isGreaterThan(0) }, { toEqual(1) })` but for `entries({ toEqual(1) }, { isGreaterThan(0) })`
+ * otherwise `isGreaterThan(0)` matches `1` before `toEqual(1)` would match it. As a consequence `toEqual(1)` could
+ * only match the entry which is left -- in this case `2` -- and of course this would fail.
+ *
+ * @param entries The entries which are expected to be contained within the [IterableLike] plus a lambda configuring
+ * the [InAnyOrderOnlyReportingOptions] -- use the function `entries(t, ..., reportOptionsInAnyOrderOnly = { ... })`
+ * to create a [WithInAnyOrderOnlyReportingOptions] with a wrapped [Entries].
+ *
+ * @return an [Expect] for the subject of `this` expectation.
+ *
+ * @since 0.18.0
+ */
+@JvmName("theEntriesWithReportingOptions")
+infix fun EntryPointStep.the(
+ entries: WithInAnyOrderOnlyReportingOptions