Skip to content

Commit

Permalink
use entries instead of deprecated keyValues
Browse files Browse the repository at this point in the history
  • Loading branch information
robstoll committed Aug 14, 2023
1 parent 1cf8e49 commit bdb7839
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ inline infix fun <K, reified V : Any, T : Map<out K, V?>> Expect<T>.toContainOnl
*/
inline infix fun <K, reified V : Any, T : Map<out K, V?>> Expect<T>.toContain(
keyValues: KeyValues<K, V>
): Expect<T> = it toContain o inAny order the keyValues(keyValues.expected, *keyValues.otherExpected)
): Expect<T> = it toContain o inAny order the entries(keyValues.expected, *keyValues.otherExpected)

/**
* Expects that the subject of `this` expectation (a [Map]) contains only (in any order) for each [KeyWithValueCreator]
Expand All @@ -172,7 +172,7 @@ inline infix fun <K, reified V : Any, T : Map<out K, V?>> Expect<T>.toContain(
*/
inline infix fun <K, reified V : Any, T : Map<out K, V?>> Expect<T>.toContainOnly(
keyValues: KeyValues<K, V>
): Expect<T> = it toContain o inAny order but only the keyValues(keyValues.expected, *keyValues.otherExpected)
): Expect<T> = it toContain o inAny order but only the entries(keyValues.expected, *keyValues.otherExpected)

/**
* Expects that the subject of `this` expectation (a [Map]) contains the key-value pairs of the given [mapLike].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ infix fun <K, V, T : MapLike> EntryPointStep<K, V, T, InAnyOrderSearchBehaviour>
*/
inline infix fun <K, reified V : Any, T : MapLike> EntryPointStep<K, out V?, T, InAnyOrderSearchBehaviour>.entry(
keyValue: KeyWithValueCreator<K, V>
): Expect<T> = this the keyValues(keyValue)
): Expect<T> = this the entries(keyValue)

/**
* Finishes the specification of the sophisticated `contains` assertion where the subject (a [MapLike])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ abstract class IterableToContainSpecBase {
val nullableList: Expect<Set<Number?>> = notImplemented()
val subList: Expect<ArrayList<out Number>> = notImplemented()
val star: Expect<Collection<*>> = notImplemented()
val any: Expect<Collection<Any>> = notImplemented()

list toContain 1
list toContain 1f
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MapToContainInAnyOrderKeyValueExpectationsSpec : Spek({
)

companion object : MapToContainSpecBase() {
val toContainKeyValue_s = "$toContain $filler $inAnyOrder $keyValue/$keyValues"
val toContainKeyValue_s = "$toContain $filler $inAnyOrder $keyValue/$theEntries"

private fun toContainKeyValues(
expect: Expect<Map<out String, Int>>,
Expand All @@ -34,7 +34,7 @@ class MapToContainInAnyOrderKeyValueExpectationsSpec : Spek({
): Expect<Map<out String, Int>> =
mapArguments(a, aX).to { keyValue(it.first, it.second) }.let { (first, others) ->
if (others.isEmpty()) expect toContain o inAny order entry first
else expect toContain o inAny order the keyValues(first, *others)
else expect toContain o inAny order the entries(first, *others)
}

private fun toContainKeyValuesNullable(
Expand All @@ -44,7 +44,7 @@ class MapToContainInAnyOrderKeyValueExpectationsSpec : Spek({
): Expect<Map<out String?, Int?>> =
mapArguments(a, aX).to { keyValue(it.first, it.second) }.let { (first, others) ->
if (others.isEmpty()) expect toContain o inAny order entry first
else expect toContain o inAny order the keyValues(first, *others)
else expect toContain o inAny order the entries(first, *others)
}

private fun toContain(
Expand All @@ -55,7 +55,7 @@ class MapToContainInAnyOrderKeyValueExpectationsSpec : Spek({
if (aX.isEmpty()) expect toContain keyValue(a.first, a.second)
else mapArguments(a, aX)
.to { keyValue(it.first, it.second) }
.let { (first, others) -> expect toContain keyValues(first, *others) }
.let { (first, others) -> expect toContain entries(first, *others) }

@JvmName("toContainNullable")
private fun toContain(
Expand All @@ -66,7 +66,7 @@ class MapToContainInAnyOrderKeyValueExpectationsSpec : Spek({
if (aX.isEmpty()) expect toContain keyValue(a.first, a.second)
else mapArguments(a, aX)
.to { keyValue(it.first, it.second) }
.let { (first, others) -> expect toContain keyValues(first, *others) }
.let { (first, others) -> expect toContain entries(first, *others) }
}


Expand All @@ -88,40 +88,33 @@ class MapToContainInAnyOrderKeyValueExpectationsSpec : Spek({
ronKeyValueMap = ronKeyValueMap toContain o inAny order entry keyValue(1) { this toEqual "a" }
starMap = starMap toContain o inAny order entry keyValue(1) { this toEqual "a" }

map = map toContain o inAny order the keyValues(keyValue(1) { this toEqual "a" })
subMap = subMap toContain o inAny order the keyValues(keyValue(1) { this toEqual "a" })
nKeyMap = nKeyMap toContain o inAny order the keyValues(keyValue(1) { this toEqual "a" })
nValueMap = nValueMap toContain o inAny order the keyValues(keyValue(1) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain o inAny order the keyValues(keyValue(1) { this toEqual "a" })
ronKeyValueMap = ronKeyValueMap toContain o inAny order the keyValues(keyValue(1) { this toEqual "a" })
starMap = starMap toContain o inAny order the keyValues(keyValue(1) { this toEqual "a" })
map = map toContain o inAny order the entries(keyValue(1) { this toEqual "a" })
subMap = subMap toContain o inAny order the entries(keyValue(1) { this toEqual "a" })
nKeyMap = nKeyMap toContain o inAny order the entries(keyValue(1) { this toEqual "a" })
nValueMap = nValueMap toContain o inAny order the entries(keyValue(1) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain o inAny order the entries(keyValue(1) { this toEqual "a" })
ronKeyValueMap = ronKeyValueMap toContain o inAny order the entries(keyValue(1) { this toEqual "a" })
starMap = starMap toContain o inAny order the entries(keyValue(1) { this toEqual "a" })

map = map toContain o inAny order the keyValues(
keyValue(1 as Number) { this toEqual "a" },
map = map toContain o inAny order the entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
subMap = subMap toContain o inAny order the keyValues(
keyValue(1 as Number) { this toEqual "a" },
subMap = subMap toContain o inAny order the entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
nKeyMap = nKeyMap toContain o inAny order the keyValues(
keyValue(1 as Number) { this toEqual "a" },
nKeyMap = nKeyMap toContain o inAny order the entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
nValueMap = nValueMap toContain o inAny order the keyValues(
keyValue(1 as Number) { this toEqual "a" },
nValueMap = nValueMap toContain o inAny order the entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
nKeyValueMap = nKeyValueMap toContain o inAny order the keyValues(
keyValue(1 as Number) { this toEqual "a" },
nKeyValueMap = nKeyValueMap toContain o inAny order the entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
ronKeyValueMap = ronKeyValueMap toContain o inAny order the keyValues(
keyValue(1 as Number) { this toEqual "a" },
ronKeyValueMap = ronKeyValueMap toContain o inAny order the entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
starMap = starMap toContain o inAny order the keyValues(
keyValue(1 as Number) { this toEqual "a" },
starMap = starMap toContain o inAny order the entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)

Expand All @@ -135,24 +128,24 @@ class MapToContainInAnyOrderKeyValueExpectationsSpec : Spek({
starMap = starMap toContain o inAny order entry keyValue(null) { this toEqual "a" }
starMap = starMap toContain o inAny order entry keyValue(null, null)

nKeyMap = nKeyMap toContain o inAny order the keyValues(keyValue(null) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain o inAny order the keyValues(keyValue(null) { this toEqual "a" })
ronKeyValueMap = ronKeyValueMap toContain o inAny order the keyValues(keyValue(null) { this toEqual "a" })
starMap = starMap toContain o inAny order the keyValues(keyValue(null) { this toEqual "a" })
nKeyMap = nKeyMap toContain o inAny order the entries(keyValue(null) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain o inAny order the entries(keyValue(null) { this toEqual "a" })
ronKeyValueMap = ronKeyValueMap toContain o inAny order the entries(keyValue(null) { this toEqual "a" })
starMap = starMap toContain o inAny order the entries(keyValue(null) { this toEqual "a" })

nKeyMap = nKeyMap toContain o inAny order the keyValues(keyValue(null) { this toEqual "a" })
nValueMap = nValueMap toContain o inAny order the keyValues(keyValue(1, null), keyValue(1) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain o inAny order the keyValues(
nKeyMap = nKeyMap toContain o inAny order the entries(keyValue(null) { this toEqual "a" })
nValueMap = nValueMap toContain o inAny order the entries(keyValue(1, null), keyValue(1) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain o inAny order the entries(
keyValue(null) { this toEqual "a" },
keyValue(null, null),
keyValue(1, null)
)
ronKeyValueMap = ronKeyValueMap toContain o inAny order the keyValues(
ronKeyValueMap = ronKeyValueMap toContain o inAny order the entries(
keyValue(null) { this toEqual "a" },
keyValue(null, null),
keyValue(1, null)
)
starMap = starMap toContain o inAny order the keyValues(
starMap = starMap toContain o inAny order the entries(
keyValue(null) { this toEqual "a" },
keyValue(null, null),
keyValue(1, null)
Expand All @@ -168,40 +161,33 @@ class MapToContainInAnyOrderKeyValueExpectationsSpec : Spek({
ronKeyValueMap = ronKeyValueMap toContain keyValue(1) { this toEqual "a" }
starMap = starMap toContain keyValue(1) { this toEqual "a" }

map = map toContain keyValues(keyValue(1) { this toEqual "a" })
subMap = subMap toContain keyValues(keyValue(1) { this toEqual "a" })
nKeyMap = nKeyMap toContain keyValues(keyValue(1) { this toEqual "a" })
nValueMap = nValueMap toContain keyValues(keyValue(1) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain keyValues(keyValue(1) { this toEqual "a" })
ronKeyValueMap = ronKeyValueMap toContain keyValues(keyValue(1) { this toEqual "a" })
starMap = starMap toContain keyValues(keyValue(1) { this toEqual "a" })
map = map toContain entries(keyValue(1) { this toEqual "a" })
subMap = subMap toContain entries(keyValue(1) { this toEqual "a" })
nKeyMap = nKeyMap toContain entries(keyValue(1) { this toEqual "a" })
nValueMap = nValueMap toContain entries(keyValue(1) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain entries(keyValue(1) { this toEqual "a" })
ronKeyValueMap = ronKeyValueMap toContain entries(keyValue(1) { this toEqual "a" })
starMap = starMap toContain entries(keyValue(1) { this toEqual "a" })

map = map toContain keyValues(
keyValue(1 as Number) { this toEqual "a" },
map = map toContain entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
subMap = subMap toContain keyValues(
keyValue(1 as Number) { this toEqual "a" },
subMap = subMap toContain entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
nKeyMap = nKeyMap toContain keyValues(
keyValue(1 as Number) { this toEqual "a" },
nKeyMap = nKeyMap toContain entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
nValueMap = nValueMap toContain keyValues(
keyValue(1 as Number) { this toEqual "a" },
nValueMap = nValueMap toContain entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
nKeyValueMap = nKeyValueMap toContain keyValues(
keyValue(1 as Number) { this toEqual "a" },
nKeyValueMap = nKeyValueMap toContain entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
ronKeyValueMap = ronKeyValueMap toContain keyValues(
keyValue(1 as Number) { this toEqual "a" },
ronKeyValueMap = ronKeyValueMap toContain entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)
starMap = starMap toContain keyValues(
keyValue(1 as Number) { this toEqual "a" },
starMap = starMap toContain entries(keyValue(1 as Number) { this toEqual "a" },
keyValue(1.2) { this toEqual "b" }
)

Expand All @@ -214,24 +200,24 @@ class MapToContainInAnyOrderKeyValueExpectationsSpec : Spek({
starMap = starMap toContain keyValue(null) { this toEqual "a" }
starMap = starMap toContain keyValue(null, null)

nKeyMap = nKeyMap toContain keyValues(keyValue(null) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain keyValues(keyValue(null) { this toEqual "a" })
ronKeyValueMap = ronKeyValueMap toContain keyValues(keyValue(null) { this toEqual "a" })
starMap = starMap toContain keyValues(keyValue(null) { this toEqual "a" })
nKeyMap = nKeyMap toContain entries(keyValue(null) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain entries(keyValue(null) { this toEqual "a" })
ronKeyValueMap = ronKeyValueMap toContain entries(keyValue(null) { this toEqual "a" })
starMap = starMap toContain entries(keyValue(null) { this toEqual "a" })

nKeyMap = nKeyMap toContain keyValues(keyValue(null) { this toEqual "a" })
nValueMap = nValueMap toContain keyValues(keyValue(1, null), keyValue(1) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain keyValues(
nKeyMap = nKeyMap toContain entries(keyValue(null) { this toEqual "a" })
nValueMap = nValueMap toContain entries(keyValue(1, null), keyValue(1) { this toEqual "a" })
nKeyValueMap = nKeyValueMap toContain entries(
keyValue(null) { this toEqual "a" },
keyValue(null, null),
keyValue(1, null)
)
ronKeyValueMap = ronKeyValueMap toContain keyValues(
ronKeyValueMap = ronKeyValueMap toContain entries(
keyValue(null) { this toEqual "a" },
keyValue(null, null),
keyValue(1, null)
)
starMap = starMap toContain keyValues(
starMap = starMap toContain entries(
keyValue(null) { this toEqual "a" },
keyValue(null, null),
keyValue(1, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MapToContainInAnyOrderKeyValuePairsExpectationsSpec : Spek({
)

companion object : MapToContainSpecBase() {
val toContainKeyValuePair_s = "$toContain $filler $inAnyOrder $keyValue/$keyValues"
val toContainKeyValuePair_s = "$toContain $filler $inAnyOrder $keyValue/$theEntries"

private fun toContainKeyValuePairs(
expect: Expect<Map<out String, Int>>,
Expand Down
Loading

0 comments on commit bdb7839

Please sign in to comment.