aboutsummaryrefslogtreecommitdiff
path: root/test-tools
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-08-05 15:38:00 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-14 14:16:41 +0200
commit0a2a5896ece71f9d37930274c86b09a5fdf38644 (patch)
tree5df828b2698a0b99d8a66ba56c3b0962cf19bc80 /test-tools
parente9ae3982e3b1e7b5dfd105a9e0cad9ccd9ee8d41 (diff)
downloaddokka-0a2a5896ece71f9d37930274c86b09a5fdf38644.tar.gz
dokka-0a2a5896ece71f9d37930274c86b09a5fdf38644.tar.bz2
dokka-0a2a5896ece71f9d37930274c86b09a5fdf38644.zip
Add tests checking omitting of obvious types
Diffstat (limited to 'test-tools')
-rw-r--r--test-tools/src/main/kotlin/matchers/content/ContentMatchersDsl.kt4
1 files changed, 3 insertions, 1 deletions
diff --git a/test-tools/src/main/kotlin/matchers/content/ContentMatchersDsl.kt b/test-tools/src/main/kotlin/matchers/content/ContentMatchersDsl.kt
index e1026a97..67c0e692 100644
--- a/test-tools/src/main/kotlin/matchers/content/ContentMatchersDsl.kt
+++ b/test-tools/src/main/kotlin/matchers/content/ContentMatchersDsl.kt
@@ -30,12 +30,14 @@ class ContentMatcherBuilder<T : ContentComposite> @PublishedApi internal constru
internal val children = mutableListOf<MatcherElement>()
internal val assertions = mutableListOf<T.() -> Unit>()
- fun build() = CompositeMatcher(kclass, children) { assertions.forEach { it() } }
+ fun build() = CompositeMatcher(kclass, childrenOrSkip()) { assertions.forEach { it() } }
// part of DSL that cannot be defined as an extension
operator fun String.unaryPlus() {
children += TextMatcher(this)
}
+
+ private fun childrenOrSkip() = if (children.isEmpty() && assertions.isNotEmpty()) listOf(Anything) else children
}
fun <T : ContentComposite> ContentMatcherBuilder<T>.check(assertion: T.() -> Unit) {