From 5451627eb0cf8d95dafd23e96665e062ef023d75 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Mon, 18 May 2020 17:14:23 +0200 Subject: Add test utils for ContentDivergent and fix the tests --- plugins/base/src/test/kotlin/utils/contentUtils.kt | 68 +++++++++++++--------- 1 file changed, 41 insertions(+), 27 deletions(-) (limited to 'plugins/base/src/test/kotlin/utils/contentUtils.kt') diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt index 8742e91a..c71409c3 100644 --- a/plugins/base/src/test/kotlin/utils/contentUtils.kt +++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt @@ -10,20 +10,26 @@ fun ContentMatcherBuilder<*>.signature( vararg params: Pair ) = platformHinted { - group { // TODO: remove it when double wrapping for signatures will be resolved - +"final fun" - link { +name } - +"(" - params.forEachIndexed { id, (n, t) -> - +"$n:" - group { link { +t } } - if (id != params.lastIndex) - +", " - } - +")" - returnType?.let { +": $it" } - } + bareSignature(name, returnType, *params) + } + +fun ContentMatcherBuilder<*>.bareSignature( + name: String, + returnType: String? = null, + vararg params: Pair +) = group { + +"final fun" + link { +name } + +"(" + params.forEachIndexed { id, (n, t) -> + +"$n:" + group { link { +t } } + if (id != params.lastIndex) + +", " } + +")" + returnType?.let { +": $it" } +} fun ContentMatcherBuilder<*>.signatureWithReceiver( receiver: String, @@ -32,21 +38,29 @@ fun ContentMatcherBuilder<*>.signatureWithReceiver( vararg params: Pair ) = platformHinted { - group { // TODO: remove it when double wrapping for signatures will be resolved - +"final fun" - group { - link { +receiver } - } - +"." - link { +name } - +"(" - params.forEach { (n, t) -> - +"$n:" - group { link { +t } } - } - +")" - returnType?.let { +": $it" } + bareSignatureWithReceiver(receiver, name, returnType, *params) + } + +fun ContentMatcherBuilder<*>.bareSignatureWithReceiver( + receiver: String, + name: String, + returnType: String? = null, + vararg params: Pair +) = + group { + +"final fun" + group { + link { +receiver } + } + +"." + link { +name } + +"(" + params.forEach { (n, t) -> + +"$n:" + group { link { +t } } } + +")" + returnType?.let { +": $it" } } -- cgit