aboutsummaryrefslogtreecommitdiff
path: root/core/content-matcher-test-utils/src/main/kotlin
diff options
context:
space:
mode:
authorGoooler <wangzongler@gmail.com>2022-02-21 22:01:06 +0800
committerGitHub <noreply@github.com>2022-02-21 17:01:06 +0300
commitf5b7797255576e5f1c230e2ca3fcb5f4e602387c (patch)
tree25fd98250066c4ed6c2fff1104be533604bbf1b9 /core/content-matcher-test-utils/src/main/kotlin
parentdf4780c31026aaa626746f49f0e6fa3fa0278a05 (diff)
downloaddokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.tar.gz
dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.tar.bz2
dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.zip
Code cleanups (#2165)
Diffstat (limited to 'core/content-matcher-test-utils/src/main/kotlin')
-rw-r--r--core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt13
1 files changed, 6 insertions, 7 deletions
diff --git a/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt b/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt
index 6a0e1c97..e2b69226 100644
--- a/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt
+++ b/core/content-matcher-test-utils/src/main/kotlin/matchers/content/contentMatchers.kt
@@ -37,7 +37,7 @@ class CompositeMatcher<T : ContentComposite>(
assertions: T.() -> Unit = {}
) : NodeMatcher<T>(kclass, assertions) {
internal val normalizedChildren: List<MatcherElement> by lazy {
- children.fold(listOf<MatcherElement>()) { acc, e ->
+ children.fold(listOf()) { acc, e ->
when {
acc.lastOrNull() is Anything && e is Anything -> acc
acc.lastOrNull() is TextMatcher && e is TextMatcher ->
@@ -119,8 +119,7 @@ private class FurtherSiblings(val list: List<MatcherElement>, val parent: Compos
fun drop() = FurtherSiblings(list.drop(1), parent)
val messageEnd: String
- get() = list.filter { it !is Anything }
- .count().takeIf { it > 0 }
+ get() = list.count { it !is Anything }.takeIf { it > 0 }
?.let { " and $it further matchers were not satisfied" } ?: ""
}
@@ -139,10 +138,10 @@ internal fun MatcherElement.toDebugString(anchor: MatcherElement?, anchorAfter:
is CompositeMatcher<*> -> {
append("${element.kclass.simpleName.toString()}\n")
if (element.normalizedChildren.isNotEmpty()) {
- val newOwnPrefix = childPrefix + '\u251c' + '\u2500' + ' '
- val lastOwnPrefix = childPrefix + '\u2514' + '\u2500' + ' '
- val newChildPrefix = childPrefix + '\u2502' + ' ' + ' '
- val lastChildPrefix = childPrefix + ' ' + ' ' + ' '
+ val newOwnPrefix = "$childPrefix├─ "
+ val lastOwnPrefix = "$childPrefix└─ "
+ val newChildPrefix = "$childPrefix│ "
+ val lastChildPrefix = "$childPrefix "
element.normalizedChildren.forEachIndexed { n, e ->
if (n != element.normalizedChildren.lastIndex) append(e, newOwnPrefix, newChildPrefix)
else append(e, lastOwnPrefix, lastChildPrefix)