Skip to content

Commit 56e5eb2

Browse files
authored
Merge pull request #1050 from robstoll/api-infix_add-report-to-in-order-only
add report option to `inGiven order only` in api-infix
2 parents f24ddb2 + f1a6b24 commit 56e5eb2

File tree

27 files changed

+671
-257
lines changed

27 files changed

+671
-257
lines changed

apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/deprecatedIterableAssertions.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.contains(
109109
*
110110
* It is a shortcut for `contains.inOrder.only.values(expected, *otherExpected)`
111111
*
112-
* Note that we might change the signature of this function with the next version
113-
* which will cause a binary backward compatibility break (see
114-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
115-
*
116112
* @return an [Expect] for the subject of `this` expectation.
117113
*/
118114
@Deprecated(
@@ -129,10 +125,6 @@ fun <E, T : Iterable<E>> Expect<T>.containsExactly(expected: E, vararg otherExpe
129125
*
130126
* It is a shortcut for `contains.inOrder.only.entry(assertionCreatorOrNull)`
131127
*
132-
* Note that we might change the signature of this function with the next version
133-
* which will cause a binary backward compatibility break (see
134-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
135-
*
136128
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
137129
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
138130
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
@@ -154,10 +146,6 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.containsExactly(assertionCreatorOrNull
154146
*
155147
* It is a shortcut for `contains.inOrder.only.entries(assertionCreatorOrNull, *otherAssertionCreatorsOrNulls)`
156148
*
157-
* Note that we might change the signature of this function with the next version
158-
* which will cause a binary backward compatibility break (see
159-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
160-
*
161149
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
162150
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
163151
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.

apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableExpectations.kt

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.toContain(
108108
* Expects that the subject of `this` expectation (an [Iterable]) contains only
109109
* the [expected] value and the [otherExpected] values (if given) in the defined order.
110110
*
111-
* It is a shortcut for `toContain.inOrder.only.values(expected, *otherExpected)`
111+
* It is a shortcut for `toContain.inOrder.only.values(expected, *otherExpected, report = { ... })`
112112
*
113-
* Note that we might change the signature of this function with the next version
114-
* which will cause a binary backward compatibility break (see
115-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
113+
* @param expected The first expected value.
114+
* @param otherExpected The other expected values in the given order.
115+
* @param report The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
116+
* the default [InOrderOnlyReportingOptions] apply if not specified.
116117
*
117118
* @return an [Expect] for the subject of `this` expectation.
118119
*
@@ -124,8 +125,7 @@ fun <E, T : Iterable<E>> Expect<T>.toContainExactly(
124125
expected: E,
125126
vararg otherExpected: E,
126127
report: InOrderOnlyReportingOptions.() -> Unit = {}
127-
): Expect<T> =
128-
toContain.inOrder.only.values(expected, *otherExpected, report = report)
128+
): Expect<T> = toContain.inOrder.only.values(expected, *otherExpected, report = report)
129129

130130
/**
131131
* Expects that the subject of `this` expectation (an [Iterable]) contains only an entry holding
@@ -134,10 +134,6 @@ fun <E, T : Iterable<E>> Expect<T>.toContainExactly(
134134
*
135135
* It is a shortcut for `toContain.inOrder.only.entry(assertionCreatorOrNull)`
136136
*
137-
* Note that we might change the signature of this function with the next version
138-
* which will cause a binary backward compatibility break (see
139-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
140-
*
141137
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
142138
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
143139
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
@@ -159,15 +155,13 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.toContainExactly(assertionCreatorOrNul
159155
*
160156
* It is a shortcut for `toContain.inOrder.only.entries(assertionCreatorOrNull, *otherAssertionCreatorsOrNulls)`
161157
*
162-
* Note that we might change the signature of this function with the next version
163-
* which will cause a binary backward compatibility break (see
164-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
165-
*
166158
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
167159
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
168160
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
169161
* @param otherAssertionCreatorsOrNulls Additional identification lambdas which each identify (separately) an entry
170162
* which we are looking for (see [assertionCreatorOrNull] for more information).
163+
* @param report The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
164+
* the default [InOrderOnlyReportingOptions] apply if not specified.
171165
*
172166
* @return an [Expect] for the subject of `this` expectation.
173167
*
@@ -192,6 +186,8 @@ fun <E : Any, T : Iterable<E?>> Expect<T>.toContainExactly(
192186
* are passed. This function expects [IterableLike] (which is a typealias for [Any]) to avoid cluttering the API.
193187
*
194188
* @param expectedIterableLike The [IterableLike] whose elements are expected to be contained within this [Iterable].
189+
* @param report The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
190+
* the default [InOrderOnlyReportingOptions] apply if not specified.
195191
*
196192
* @return an [Expect] for the subject of `this` expectation.
197193
* @throws IllegalArgumentException in case [expectedIterableLike] is not an [Iterable], [Sequence] or one of the [Array] types or the given

apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInAnyOrderOnlyCreators.kt

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ import ch.tutteli.kbox.glue
2020
*
2121
* Delegates to [values].
2222
*
23-
* Note that we might change the signature of this function with the next version
24-
* which will cause a binary backward compatibility break (see
25-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
26-
*
2723
* @param expected The value which is expected to be contained within the subject (an [IterableLike]).
2824
*
2925
* @return an [Expect] for the subject of `this` expectation.
@@ -38,10 +34,6 @@ fun <E, T: IterableLike> EntryPointStep<E, T, InAnyOrderOnlySearchBehaviour>.val
3834
* needs to contain only the [expected] value as well as the [otherExpected] values
3935
* where it does not matter in which order.
4036
*
41-
* Note that we might change the signature of this function with the next version
42-
* which will cause a binary backward compatibility break (see
43-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
44-
*
4537
* @param expected The value which is expected to be contained within the subject (an [IterableLike]).
4638
* @param otherExpected Additional values which are expected to be contained within [IterableLike].
4739
*
@@ -61,10 +53,6 @@ fun <E, T: IterableLike> EntryPointStep<E, T, InAnyOrderOnlySearchBehaviour>.val
6153
*
6254
* Delegates to [entries].
6355
*
64-
* Note that we might change the signature of this function with the next version
65-
* which will cause a binary backward compatibility break (see
66-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
67-
*
6856
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
6957
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
7058
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
@@ -92,10 +80,6 @@ fun <E : Any, T: IterableLike> EntryPointStep<out E?, T, InAnyOrderOnlySearchBeh
9280
* `isGreaterThan(0)` matches `1` before `toEqual(1)` would match it. As a consequence `toEqual(1)` could only match the
9381
* entry which is left -- in this case `2` -- and of course this would fail.
9482
*
95-
* Note that we might change the signature of this function with the next version
96-
* which will cause a binary backward compatibility break (see
97-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
98-
*
9983
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
10084
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
10185
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
@@ -121,10 +105,6 @@ fun <E : Any, T: IterableLike> EntryPointStep<out E?, T, InAnyOrderOnlySearchBeh
121105
* are passed (this can be changed via [IterableLikeToIterableTransformer]).
122106
* This function expects [IterableLike] (which is a typealias for [Any]) to avoid cluttering the API.
123107
*
124-
* Note that we might change the signature of this function with the next version
125-
* which will cause a binary backward compatibility break (see
126-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
127-
*
128108
* @param expectedIterableLike The [IterableLike] whose elements are expected to be contained within this [IterableLike]
129109
*
130110
* @return an [Expect] for the subject of `this` expectation.

apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInOrderOnlyCreators.kt

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ import ch.tutteli.kbox.glue
1919
*
2020
* Delegates to [values].
2121
*
22-
* Note that we might change the signature of this function with the next version
23-
* which will cause a binary backward compatibility break (see
24-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
25-
*
2622
* @param expected The value which is expected to be contained within the subject (an [IterableLike]).
2723
*
2824
* @return an [Expect] for the subject of `this` expectation.
@@ -37,12 +33,10 @@ fun <E, T : IterableLike> EntryPointStep<E, T, InOrderOnlySearchBehaviour>.value
3733
* needs to contain only the [expected] value as well as the [otherExpected] values
3834
* in the specified order.
3935
*
40-
* Note that we might change the signature of this function with the next version
41-
* which will cause a binary backward compatibility break (see
42-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
43-
*
4436
* @param expected The value which is expected to be contained within the subject (an [IterableLike]).
4537
* @param otherExpected Additional values which are expected to be contained within [IterableLike].
38+
* @param report The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
39+
* the default [InOrderOnlyReportingOptions] apply if not specified.
4640
*
4741
* @return an [Expect] for the subject of `this` expectation.
4842
*
@@ -61,10 +55,6 @@ fun <E, T : IterableLike> EntryPointStep<E, T, InOrderOnlySearchBehaviour>.value
6155
*
6256
* Delegates to `entries(assertionCreatorOrNull)`.
6357
*
64-
* Note that we might change the signature of this function with the next version
65-
* which will cause a binary backward compatibility break (see
66-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
67-
*
6858
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
6959
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
7060
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
@@ -84,15 +74,13 @@ fun <E : Any, T : IterableLike> EntryPointStep<out E?, T, InOrderOnlySearchBehav
8474
* holds all assertions [assertionCreatorOrNull] creates or
8575
* needs to be `null` in case [assertionCreatorOrNull] is defined as `null`.
8676
*
87-
* Note that we might change the signature of this function with the next version
88-
* which will cause a binary backward compatibility break (see
89-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
90-
*
9177
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
9278
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
9379
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
9480
* @param otherAssertionCreatorsOrNulls Additional identification lambdas which each identify (separately) an entry
9581
* which we are looking for (see [assertionCreatorOrNull] for more information).
82+
* @param report The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
83+
* the default [InOrderOnlyReportingOptions] apply if not specified.
9684
*
9785
* @return an [Expect] for the subject of `this` expectation.
9886
*
@@ -114,11 +102,9 @@ fun <E : Any, T : IterableLike> EntryPointStep<out E?, T, InOrderOnlySearchBehav
114102
* are passed (this can be changed via [IterableLikeToIterableTransformer]).
115103
* This function expects [IterableLike] (which is a typealias for [Any]) to avoid cluttering the API.
116104
*
117-
* Note that we might change the signature of this function with the next version
118-
* which will cause a binary backward compatibility break (see
119-
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
120-
*
121105
* @param expectedIterableLike The [IterableLike] whose elements are expected to be contained within this [IterableLike].
106+
* @param report The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
107+
* the default [InOrderOnlyReportingOptions] apply if not specified.
122108
*
123109
* @return an [Expect] for the subject of `this` expectation.
124110
* @throws IllegalArgumentException in case [expectedIterableLike] is not an

apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/main/kotlin/ch/tutteli/atrium/api/fluent/en_GB/iterableLikeToContainInOrderOnlyGroupedCreators.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import kotlin.jvm.JvmName
2222
* within the [IterableLike].
2323
* @param otherExpectedGroups Additional groups of values which are expected to appear after the [secondGroup] within
2424
* [IterableLike] whereas the groups have to appear in the given order.
25+
* @param report The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
26+
* the default [InOrderOnlyReportingOptions] apply if not specified.
2527
*
2628
* @return an [Expect] for the subject of `this` expectation.
2729
*
@@ -50,6 +52,8 @@ fun <E, T : IterableLike> EntryPointStep<E, T, InOrderOnlyGroupedWithinSearchBeh
5052
* within the [IterableLike].
5153
* @param otherExpectedGroups Additional groups of values which are expected to appear after the [secondGroup] within
5254
* [IterableLike] whereas the groups have to appear in the given order.
55+
* @param report The lambda configuring the [InOrderOnlyReportingOptions] -- it is optional where
56+
* the default [InOrderOnlyReportingOptions] apply if not specified.
5357
*
5458
* @return an [Expect] for the subject of `this` expectation.
5559
*

apis/fluent-en_GB/atrium-api-fluent-en_GB-common/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/IterableToContainInOrderOnlyElementsOfExpectationsSpec.kt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,17 @@ class IterableToContainInOrderOnlyElementsOfExpectationsSpec : Spek({
5252
aX: Array<out Double>,
5353
report: InOrderOnlyReportingOptions.() -> Unit
5454
): Expect<Iterable<Double>> =
55-
//TODO 0.18.0 remove if once implemented
5655
if (report === emptyInOrderOnlyReportOptions) expect.toContain.inOrder.only.elementsOf(listOf(a, *aX))
57-
else expect.toContain.inOrder.only._logicAppend { valuesInOrderOnly(listOf(a, *aX), report) }
56+
else expect.toContain.inOrder.only.elementsOf(listOf(a, *aX), report = report)
5857

5958
private fun toContainInOrderOnlyNullableValues(
6059
expect: Expect<Iterable<Double?>>,
6160
a: Double?,
6261
aX: Array<out Double?>,
6362
report: InOrderOnlyReportingOptions.() -> Unit = {}
6463
): Expect<Iterable<Double?>> =
65-
//TODO 0.18.0 remove if once implemented
6664
if (report === emptyInOrderOnlyReportOptions) expect.toContain.inOrder.only.elementsOf(sequenceOf(a, *aX))
67-
else expect.toContain.inOrder.only._logicAppend { valuesInOrderOnly(listOf(a, *aX), report) }
65+
else expect.toContain.inOrder.only.elementsOf(listOf(a, *aX), report = report)
6866

6967
private fun toContainExactlyElementsOfShortcut(
7068
expect: Expect<Iterable<Double>>,
@@ -81,7 +79,6 @@ class IterableToContainInOrderOnlyElementsOfExpectationsSpec : Spek({
8179
): Expect<Iterable<Double?>> = expect.toContainExactlyElementsOf(sequenceOf(a, *aX).asIterable(), report)
8280
}
8381

84-
8582
@Suppress("unused", "UNUSED_VALUE")
8683
private fun ambiguityTest() {
8784
var list: Expect<List<Number>> = notImplemented()
@@ -93,16 +90,16 @@ class IterableToContainInOrderOnlyElementsOfExpectationsSpec : Spek({
9390
nList = nList.toContain.inOrder.only.elementsOf(listOf<Int>())
9491
subList = subList.toContain.inOrder.only.elementsOf(listOf<Int>())
9592
star = star.toContain.inOrder.only.elementsOf(listOf<Int>())
96-
//TODO use the following with 0.18.0
97-
// list = list.toContain.inOrder.only.elementsOf(listOf<Int>(), report = { showAlwaysSummary() })
98-
// nList = nList.toContain.inOrder.only.elementsOf(listOf<Int>(), report = { showOnlyFailing() })
99-
// subList = subList.toContain.inOrder.only.elementsOf(listOf<Int>(), report = { })
100-
// star = star.toContain.inOrder.only.elementsOf(listOf<Int>(), report = { })
101-
102-
list = list.toContainExactlyElementsOf(1, report = { })
103-
nList = nList.toContainExactlyElementsOf(1, report = { })
104-
subList = subList.toContainExactlyElementsOf(1, report = { })
105-
star = star.toContainExactlyElementsOf(1, report = { })
93+
94+
list = list.toContain.inOrder.only.elementsOf(listOf<Int>(), report = { showAlwaysSummary() })
95+
nList = nList.toContain.inOrder.only.elementsOf(listOf<Int>(), report = { showOnlyFailing() })
96+
subList = subList.toContain.inOrder.only.elementsOf(listOf<Int>(), report = { })
97+
star = star.toContain.inOrder.only.elementsOf(listOf<Int>(), report = { })
98+
99+
list = list.toContainExactlyElementsOf(listOf(1))
100+
nList = nList.toContainExactlyElementsOf(listOf(1))
101+
subList = subList.toContainExactlyElementsOf(listOf(1))
102+
star = star.toContainExactlyElementsOf(listOf(1))
106103

107104
list = list.toContainExactlyElementsOf(listOf(1, 1.2), report = { })
108105
nList = nList.toContainExactlyElementsOf(listOf(1, 1.2), report = { })

0 commit comments

Comments
 (0)