From f5b7797255576e5f1c230e2ca3fcb5f4e602387c Mon Sep 17 00:00:00 2001 From: Goooler Date: Mon, 21 Feb 2022 22:01:06 +0800 Subject: Code cleanups (#2165) --- .../src/main/kotlin/matchers/content/contentMatchers.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'core/content-matcher-test-utils/src/main/kotlin') 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( assertions: T.() -> Unit = {} ) : NodeMatcher(kclass, assertions) { internal val normalizedChildren: List by lazy { - children.fold(listOf()) { 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, 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) -- cgit