diff options
Diffstat (limited to 'plugins/base/src/test')
4 files changed, 408 insertions, 267 deletions
diff --git a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt index 4a6b5264..fbed41fc 100644 --- a/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt +++ b/plugins/base/src/test/kotlin/content/params/ContentForParamsTest.kt @@ -4,10 +4,7 @@ import matchers.content.* import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.junit.jupiter.api.Test -import utils.pWrapped -import utils.signature -import utils.signatureWithReceiver -import utils.unnamedTag +import utils.* class ContentForParamsTest : AbstractCoreTest() { private val testConfiguration = dokkaConfiguration { @@ -36,9 +33,13 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + } } } } @@ -63,13 +64,19 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + after { + header(3) { +"Description" } + platformHinted { + pWrapped("comment to function") + } + } + } } } } @@ -95,14 +102,20 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - unnamedTag("Author") { +"Kordyjan" } - unnamedTag("Since") { +"0.11" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + after { + header(3) { +"Description" } + platformHinted { + unnamedTag("Author") { +"Kordyjan" } + unnamedTag("Since") { +"0.11" } + } + } + } } } } @@ -129,15 +142,21 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - unnamedTag("Author") { +"Kordyjan" } - unnamedTag("Since") { +"0.11" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + after { + header(3) { +"Description" } + platformHinted { + pWrapped("comment to function") + unnamedTag("Author") { +"Kordyjan" } + unnamedTag("Since") { +"0.11" } + } + } + } } } } @@ -163,18 +182,24 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - header(4) { +"Parameters" } - table { - group { - +"abc" - group { +"comment to param" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + after { + header(3) { +"Description" } + platformHinted { + pWrapped("comment to function") + header(4) { +"Parameters" } + table { + group { + +"abc" + group { +"comment to param" } + } + } + } } } } @@ -204,26 +229,38 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "first" to "String", "second" to "Int", "third" to "Double") - } - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - header(4) { +"Parameters" } - table { - group { - +"first" - group { +"comment to first param" } - } - group { - +"second" - group { +"comment to second param" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature( + "function", + null, + "first" to "String", + "second" to "Int", + "third" to "Double" + ) } - group { - +"third" - group { +"comment to third param" } + after { + header(3) { +"Description" } + platformHinted { + pWrapped("comment to function") + header(4) { +"Parameters" } + table { + group { + +"first" + group { +"comment to first param" } + } + group { + +"second" + group { +"comment to second param" } + } + group { + +"third" + group { +"comment to third param" } + } + } + } } } } @@ -252,25 +289,37 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "first" to "String", "second" to "Int", "third" to "Double") - } - header(3) { +"Description" } - platformHinted { - header(4) { +"Parameters" } - table { - group { - +"first" - group { +"comment to first param" } - } - group { - +"second" - group { +"comment to second param" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature( + "function", + null, + "first" to "String", + "second" to "Int", + "third" to "Double" + ) } - group { - +"third" - group { +"comment to third param" } + after { + header(3) { +"Description" } + platformHinted { + header(4) { +"Parameters" } + table { + group { + +"first" + group { +"comment to first param" } + } + group { + +"second" + group { +"comment to second param" } + } + group { + +"third" + group { +"comment to third param" } + } + } + } } } } @@ -299,22 +348,28 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signatureWithReceiver("String", "function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - header(4) { +"Parameters" } - table { - group { - +"<receiver>" - group { +"comment to receiver" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignatureWithReceiver("String", "function", null, "abc" to "String") } - group { - +"abc" - group { +"comment to param" } + after { + header(3) { +"Description" } + platformHinted { + pWrapped("comment to function") + header(4) { +"Parameters" } + table { + group { + +"<receiver>" + group { +"comment to receiver" } + } + group { + +"abc" + group { +"comment to param" } + } + } + } } } } @@ -343,22 +398,34 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "first" to "String", "second" to "Int", "third" to "Double") - } - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - header(4) { +"Parameters" } - table { - group { - +"first" - group { +"comment to first param" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature( + "function", + null, + "first" to "String", + "second" to "Int", + "third" to "Double" + ) } - group { - +"third" - group { +"comment to third param" } + after { + header(3) { +"Description" } + platformHinted { + pWrapped("comment to function") + header(4) { +"Parameters" } + table { + group { + +"first" + group { +"comment to first param" } + } + group { + +"third" + group { +"comment to third param" } + } + } + } } } } @@ -390,30 +457,42 @@ class ContentForParamsTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "first" to "String", "second" to "Int", "third" to "Double") - } - header(3) { +"Description" } - platformHinted { - pWrapped("comment to function") - header(4) { +"Parameters" } - table { - group { - +"first" - group { +"comment to first param" } - } - group { - +"second" - group { +"comment to second param" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature( + "function", + null, + "first" to "String", + "second" to "Int", + "third" to "Double" + ) } - group { - +"third" - group { +"comment to third param" } + after { + header(3) { +"Description" } + platformHinted { + pWrapped("comment to function") + header(4) { +"Parameters" } + table { + group { + +"first" + group { +"comment to first param" } + } + group { + +"second" + group { +"comment to second param" } + } + group { + +"third" + group { +"comment to third param" } + } + } + unnamedTag("Author") { +"Kordyjan" } + unnamedTag("Since") { +"0.11" } + } } } - unnamedTag("Author") { +"Kordyjan" } - unnamedTag("Since") { +"0.11" } } } } diff --git a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt index ae53a848..8121543d 100644 --- a/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt +++ b/plugins/base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt @@ -1,10 +1,11 @@ package content.seealso + import matchers.content.* import org.jetbrains.dokka.pages.ContentPage import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest import org.junit.jupiter.api.Test +import utils.bareSignature import utils.pWrapped -import utils.signature import utils.unnamedTag class ContentForSeeAlsoTest : AbstractCoreTest() { @@ -34,9 +35,13 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + } } } } @@ -61,18 +66,24 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "test//abc/#/-1/" - link{ +"abc" } - group { } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + after { + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"abc" } + group { } + } + } + } } } } @@ -99,18 +110,24 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "test//abc/#/-1/" - link{ +"abc" } - group { +"Comment to abc" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + after { + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"abc" } + group { +"Comment to abc" } + } + } + } } } } @@ -137,18 +154,24 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "kotlin.collections/Collection////" - link{ +"Collection"} - group { } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + after { + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "kotlin.collections/Collection////" + link { +"Collection" } + group { } + } + } + } } } } @@ -175,18 +198,25 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "test//abc/#/-1/" - link{ +"Collection" } - group { +"Comment to stdliblink" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + after { + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"Collection" } + group { +"Comment to stdliblink" } + } + } + } + } } } @@ -216,21 +246,27 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - pWrapped("random comment") - unnamedTag("Author") { +"pikinier20" } - unnamedTag("Since") { +"0.11" } - header(4) { +"See also" } - table { - group { - //DRI should be "test//abc/#/-1/" - link{ +"Collection" } - group { +"Comment to stdliblink" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + after { + header(3) { +"Description" } + platformHinted { + pWrapped("random comment") + unnamedTag("Author") { +"pikinier20" } + unnamedTag("Since") { +"0.11" } + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"Collection" } + group { +"Comment to stdliblink" } + } + } + } } } } @@ -258,18 +294,24 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "test//abc/#/-1/" - link{ +"abc" } - group { +"Comment to abc2" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") + } + after { + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"abc" } + group { +"Comment to abc2" } + } + } + } } } } @@ -297,23 +339,29 @@ class ContentForSeeAlsoTest : AbstractCoreTest() { val page = module.children.single { it.name == "test" } .children.single { it.name == "function" } as ContentPage page.content.assertNode { - group { - header(1) { +"function" } - signature("function", null, "abc" to "String") - } - header(3) { +"Description" } - platformHinted { - header(4) { +"See also" } - table { - group { - //DRI should be "test//abc/#/-1/" - link{ +"abc" } - group { +"Comment to abc1" } + header(1) { +"function" } + divergentGroup { + divergentInstance { + divergent { + bareSignature("function", null, "abc" to "String") } - group { - //DRI should be "test//abc/#/-1/" - link{ +"Collection" } - group { +"Comment to collection" } + after { + header(3) { +"Description" } + platformHinted { + header(4) { +"See also" } + table { + group { + //DRI should be "test//abc/#/-1/" + link { +"abc" } + group { +"Comment to abc1" } + } + group { + //DRI should be "test//abc/#/-1/" + link { +"Collection" } + group { +"Comment to collection" } + } + } + } } } } diff --git a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt index fc6d22ac..1f310502 100644 --- a/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt +++ b/plugins/base/src/test/kotlin/renderers/html/DivergentTest.kt @@ -30,7 +30,7 @@ class DivergentTest : RenderingOnlyTestBase() { } } HtmlRenderer(context).render(page) - renderedContent.match(Div(Div("a"))) + renderedContent.match(Div(Div(Div("a")))) } @Test @@ -45,7 +45,7 @@ class DivergentTest : RenderingOnlyTestBase() { } } HtmlRenderer(context).render(page) - renderedContent.match("a") + renderedContent.match(Div("a")) } @Test @@ -71,7 +71,7 @@ class DivergentTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match(Div(Div("a"), Div("b"), Div("c"))) + renderedContent.match(Div(Div(Div("a"), Div("b"), Div("c")))) } @Test @@ -97,7 +97,7 @@ class DivergentTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match(Div(Div("abc"))) + renderedContent.match(Div(Div(Div("abc")))) } @Test @@ -133,7 +133,7 @@ class DivergentTest : RenderingOnlyTestBase() { } HtmlRenderer(context).render(page) - renderedContent.match(Div(Div("ae"), Div("bd"), Div("c"))) + renderedContent.match(Div(Div(Div("ae"), Div("bd"), Div("c")))) } @Test @@ -182,12 +182,12 @@ class DivergentTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match( - Div(Div("a")), + Div(Div(Div("a")), Div(Div())), "a+", - Div(Div("bd")), + Div(Div(Div("bd")), Div(Div())), "bd+", - Div(Div("c")), - Div(Div("e")), + Div(Div(Div("c")), Div(Div())), + Div(Div(Div("e")), Div(Div())), "e+" ) } @@ -218,7 +218,7 @@ class DivergentTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match( "ab-", - Div(Div("ab")) + Div(Div(Div("ab"))) ) } @@ -247,7 +247,7 @@ class DivergentTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match( - Div(Div("ab")), + Div(Div(Div("ab"))), "ab+" ) } @@ -284,7 +284,7 @@ class DivergentTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match( "ab-", - Div(Div("ab")), + Div(Div(Div("ab"))), "ab+" ) } @@ -321,9 +321,9 @@ class DivergentTest : RenderingOnlyTestBase() { HtmlRenderer(context).render(page) renderedContent.match( "a-", - Div(Div("a")), + Div(Div(Div("a")), Div(Div("NATIVE"))), "ab+b-", - Div(Div("b")), + Div(Div(Div("b")), Div(Div("NATIVE"))), "ab+" ) } 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<String, String> ) = 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<String, String> +) = 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<String, String> ) = 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<String, String> +) = + group { + +"final fun" + group { + link { +receiver } + } + +"." + link { +name } + +"(" + params.forEach { (n, t) -> + +"$n:" + group { link { +t } } } + +")" + returnType?.let { +": $it" } } |