aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test
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 /plugins/base/src/test
parentdf4780c31026aaa626746f49f0e6fa3fa0278a05 (diff)
downloaddokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.tar.gz
dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.tar.bz2
dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.zip
Code cleanups (#2165)
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r--plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt4
-rw-r--r--plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt4
-rw-r--r--plugins/base/src/test/kotlin/model/ClassesTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/model/CommentTest.kt8
-rw-r--r--plugins/base/src/test/kotlin/model/FunctionsTest.kt8
-rw-r--r--plugins/base/src/test/kotlin/model/JavaTest.kt7
-rw-r--r--plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt8
-rw-r--r--plugins/base/src/test/kotlin/signatures/AbstractRenderingTest.kt13
-rw-r--r--plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt3
-rw-r--r--plugins/base/src/test/kotlin/utils/TestUtils.kt2
-rw-r--r--plugins/base/src/test/resources/linkable/samples/jsMain/kotlin/JsClass.kt2
-rw-r--r--plugins/base/src/test/resources/linkable/samples/jvmMain/kotlin/JvmClass.kt2
-rw-r--r--plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt6
14 files changed, 34 insertions, 37 deletions
diff --git a/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt b/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt
index e6f2c5e9..295a969b 100644
--- a/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt
+++ b/plugins/base/src/test/kotlin/filter/DeprecationFilterTest.kt
@@ -92,7 +92,7 @@ class DeprecationFilterTest : BaseAbstractTest() {
) {
preMergeDocumentablesTransformationStage = {
Assertions.assertTrue(
- it.first().packages.first().functions.size == 0
+ it.first().packages.first().functions.isEmpty()
)
}
}
@@ -132,7 +132,7 @@ class DeprecationFilterTest : BaseAbstractTest() {
) {
preMergeDocumentablesTransformationStage = {
Assertions.assertTrue(
- it.first().packages.first().functions.size == 0
+ it.first().packages.first().functions.isEmpty()
)
}
}
diff --git a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt
index 51ef4e83..3b333445 100644
--- a/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt
+++ b/plugins/base/src/test/kotlin/filter/VisibilityFilterTest.kt
@@ -458,7 +458,7 @@ class VisibilityFilterTest : BaseAbstractTest() {
) {
preMergeDocumentablesTransformationStage = {
Assertions.assertTrue(
- it.first().packages.first().functions.size == 0
+ it.first().packages.first().functions.isEmpty()
)
}
}
@@ -602,7 +602,7 @@ class VisibilityFilterTest : BaseAbstractTest() {
) {
preMergeDocumentablesTransformationStage = {
Assertions.assertTrue(
- it.first().packages.first().functions.size == 0
+ it.first().packages.first().functions.isEmpty()
)
}
}
diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt
index b05ed4fb..920dea10 100644
--- a/plugins/base/src/test/kotlin/model/ClassesTest.kt
+++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt
@@ -322,7 +322,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
constructors.map { it.name } allEquals "C"
- with(constructors.find { it.parameters.isNullOrEmpty() } notNull "C()") {
+ with(constructors.find { it.parameters.isEmpty() } notNull "C()") {
parameters counts 0
}
diff --git a/plugins/base/src/test/kotlin/model/CommentTest.kt b/plugins/base/src/test/kotlin/model/CommentTest.kt
index 613576ae..59b1817a 100644
--- a/plugins/base/src/test/kotlin/model/CommentTest.kt
+++ b/plugins/base/src/test/kotlin/model/CommentTest.kt
@@ -175,11 +175,9 @@ class CommentTest : AbstractModelTest("/src/main/kotlin/comment/Test.kt", "comme
) {
with((this / "comment" / "property").cast<DProperty>()) {
comments() equals "Summary\n\none: []"
- docs().find { it is CustomTagWrapper && it.name == "one" }.let {
- with(it.assertNotNull("'one' entry")) {
- root.children counts 0
- root.params.keys counts 0
- }
+ with(docs().find { it is CustomTagWrapper && it.name == "one" }.assertNotNull("'one' entry")) {
+ root.children counts 0
+ root.params.keys counts 0
}
}
}
diff --git a/plugins/base/src/test/kotlin/model/FunctionsTest.kt b/plugins/base/src/test/kotlin/model/FunctionsTest.kt
index eca5daea..29c81a65 100644
--- a/plugins/base/src/test/kotlin/model/FunctionsTest.kt
+++ b/plugins/base/src/test/kotlin/model/FunctionsTest.kt
@@ -44,7 +44,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
) {
with((this / "function").cast<DPackage>()) {
val fn1 = functions.find {
- it.name == "fn" && it.parameters.isNullOrEmpty()
+ it.name == "fn" && it.parameters.isEmpty()
}.assertNotNull("fn()")
val fn2 = functions.find {
it.name == "fn" && it.parameters.isNotEmpty()
@@ -81,7 +81,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
) {
with((this / "function").cast<DPackage>()) {
val fn1 = functions.find {
- it.name == "fn" && it.parameters.isNullOrEmpty()
+ it.name == "fn" && it.parameters.isEmpty()
}.assertNotNull("fn()")
val fn2 = functions.find {
it.name == "fn" && it.parameters.count() == 1
@@ -228,7 +228,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
with((this / "function" / "Fancy").cast<DAnnotation>()) {
with(extra[Annotations]!!.directAnnotations.entries.single().value.assertNotNull("Annotations")) {
this counts 3
- with(map { it.dri.classNames to it }.toMap()) {
+ with(associate { it.dri.classNames to it }) {
with(this["Target"].assertNotNull("Target")) {
(params["allowedTargets"].assertNotNull("allowedTargets") as ArrayValue).value equals listOf(
EnumValue(
@@ -298,7 +298,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
with(extra[Annotations]!!.directAnnotations.entries.single().value.assertNotNull("Annotations")) {
this counts 3
- with(map { it.dri.classNames to it }.toMap()) {
+ with(associate { it.dri.classNames to it }) {
with(this["Target"].assertNotNull("Target")) {
(params["allowedTargets"].assertNotNull("allowedTargets") as ArrayValue).value equals listOf(
EnumValue(
diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt
index aa132f6e..748ef190 100644
--- a/plugins/base/src/test/kotlin/model/JavaTest.kt
+++ b/plugins/base/src/test/kotlin/model/JavaTest.kt
@@ -52,7 +52,10 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
with((this / "fn").cast<DFunction>()) {
name equals "fn"
val params = parameters.map { it.documentation.values.first().children.first() as Param }
- params.mapNotNull { it.firstMemberOfType<Text>()?.body } equals listOf("is String parameter", "is int parameter")
+ params.map { it.firstMemberOfType<Text>().body } equals listOf(
+ "is String parameter",
+ "is int parameter"
+ )
}
}
}
@@ -160,7 +163,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
constructors counts 2
constructors.forEach { it.name equals "Test" }
- constructors.find { it.parameters.isNullOrEmpty() }.assertNotNull("Test()")
+ constructors.find { it.parameters.isEmpty() }.assertNotNull("Test()")
with(constructors.find { it.parameters.isNotEmpty() }.assertNotNull("Test(String)")) {
parameters.firstOrNull()?.type?.name equals "String"
diff --git a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt
index 13892408..94fcd5bf 100644
--- a/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt
+++ b/plugins/base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt
@@ -48,11 +48,11 @@ abstract class HtmlRenderingOnlyTestBase : RenderingOnlyTestBase<Element>() {
)
override val context = MockContext(
- DokkaBase().outputWriter to { _ -> files },
+ DokkaBase().outputWriter to { files },
DokkaBase().locationProviderFactory to ::DokkaLocationProviderFactory,
- DokkaBase().htmlPreprocessors to { _ -> RootCreator },
- DokkaBase().externalLocationProviderFactory to { ::JavadocExternalLocationProviderFactory },
- DokkaBase().externalLocationProviderFactory to { ::DefaultExternalLocationProviderFactory },
+ DokkaBase().htmlPreprocessors to { RootCreator },
+ DokkaBase().externalLocationProviderFactory to ::JavadocExternalLocationProviderFactory,
+ DokkaBase().externalLocationProviderFactory to ::DefaultExternalLocationProviderFactory,
DokkaBase().tabSortingStrategy to { DefaultTabSortingStrategy() },
testConfiguration = configuration
)
diff --git a/plugins/base/src/test/kotlin/signatures/AbstractRenderingTest.kt b/plugins/base/src/test/kotlin/signatures/AbstractRenderingTest.kt
index 171e510c..65ac1224 100644
--- a/plugins/base/src/test/kotlin/signatures/AbstractRenderingTest.kt
+++ b/plugins/base/src/test/kotlin/signatures/AbstractRenderingTest.kt
@@ -3,11 +3,13 @@ package signatures
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
+import org.jsoup.select.Elements
import utils.TestOutputWriterPlugin
+import java.nio.file.Path
import java.nio.file.Paths
abstract class AbstractRenderingTest : BaseAbstractTest() {
- val testDataDir = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath()
+ val testDataDir: Path = getTestDataDir("multiplatform/basicMultiplatformTest").toAbsolutePath()
val configuration = dokkaConfiguration {
moduleName = "example"
@@ -42,11 +44,14 @@ abstract class AbstractRenderingTest : BaseAbstractTest() {
}
}
- fun TestOutputWriterPlugin.renderedContent(path: String) = writer.contents.getValue(path)
+ fun TestOutputWriterPlugin.renderedContent(path: String): Element = writer.contents.getValue(path)
.let { Jsoup.parse(it) }.select("#content").single()
- fun TestOutputWriterPlugin.renderedDivergentContent(path: String) = renderedContent(path).select("div.divergent-group")
- fun TestOutputWriterPlugin.renderedSourceDepenentContent(path: String) = renderedContent(path).select("div.sourceset-depenent-content")
+ fun TestOutputWriterPlugin.renderedDivergentContent(path: String): Elements =
+ renderedContent(path).select("div.divergent-group")
+
+ fun TestOutputWriterPlugin.renderedSourceDepenentContent(path: String): Elements =
+ renderedContent(path).select("div.sourceset-depenent-content")
val Element.brief: String
get() = children().select("p").text()
diff --git a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
index a6f9af7d..8685e3c9 100644
--- a/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
+++ b/plugins/base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt
@@ -1,4 +1,4 @@
-package transformerBuilders;
+package transformerBuilders
import org.jetbrains.dokka.CoreExtensions
import org.jetbrains.dokka.pages.*
diff --git a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt
index d8ea90d7..6c9c351f 100644
--- a/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt
+++ b/plugins/base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt
@@ -2,15 +2,12 @@ package transformers
import org.jetbrains.dokka.base.transformers.documentables.ModuleAndPackageDocumentationReader
import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.model.DPackage
import org.jetbrains.dokka.plugability.DokkaContext
import org.jetbrains.dokka.utilities.DokkaConsoleLogger
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import testApi.testRunner.TestDokkaConfigurationBuilder
import testApi.testRunner.dPackage
-import testApi.testRunner.dokkaConfiguration
-import testApi.testRunner.sourceSet
import kotlin.test.assertEquals
class ContextModuleAndPackageDocumentationReaderTest3 : AbstractContextModuleAndPackageDocumentationReaderTest() {
diff --git a/plugins/base/src/test/kotlin/utils/TestUtils.kt b/plugins/base/src/test/kotlin/utils/TestUtils.kt
index a0528acd..99082110 100644
--- a/plugins/base/src/test/kotlin/utils/TestUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/TestUtils.kt
@@ -24,7 +24,7 @@ abstract class ModelDSL : BaseAbstractTest() {
interface AssertDSL {
infix fun Any?.equals(other: Any?) = assertEquals(other, this)
infix fun Collection<Any>?.allEquals(other: Any?) =
- this?.also { c -> c.forEach { it equals other } } ?: run { assert(false) { "Collection is empty" } }
+ this?.onEach { it equals other } ?: run { assert(false) { "Collection is empty" } }
infix fun <T> Collection<T>?.exists(e: T) {
assertTrue(this.orEmpty().isNotEmpty(), "Collection cannot be null or empty")
assertTrue(this!!.any{it == e}, "Collection doesn't contain $e")
diff --git a/plugins/base/src/test/resources/linkable/samples/jsMain/kotlin/JsClass.kt b/plugins/base/src/test/resources/linkable/samples/jsMain/kotlin/JsClass.kt
index b61ce704..b4f66be9 100644
--- a/plugins/base/src/test/resources/linkable/samples/jsMain/kotlin/JsClass.kt
+++ b/plugins/base/src/test/resources/linkable/samples/jsMain/kotlin/JsClass.kt
@@ -5,5 +5,5 @@ class JsClass {
/**
* @sample samples.SamplesJs.exampleUsage
*/
- fun printWithExclamation(msg: String) = println(msg + "!")
+ fun printWithExclamation(msg: String) = println("$msg!")
} \ No newline at end of file
diff --git a/plugins/base/src/test/resources/linkable/samples/jvmMain/kotlin/JvmClass.kt b/plugins/base/src/test/resources/linkable/samples/jvmMain/kotlin/JvmClass.kt
index 960184e6..22d44152 100644
--- a/plugins/base/src/test/resources/linkable/samples/jvmMain/kotlin/JvmClass.kt
+++ b/plugins/base/src/test/resources/linkable/samples/jvmMain/kotlin/JvmClass.kt
@@ -5,5 +5,5 @@ class JvmClass {
/**
* @sample samples.SamplesJvm.exampleUsage
*/
- fun printWithExclamation(msg: String) = println(msg + "!")
+ fun printWithExclamation(msg: String) = println("$msg!")
} \ No newline at end of file
diff --git a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt
index 6ad73db7..237cf66f 100644
--- a/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt
+++ b/plugins/base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt
@@ -19,12 +19,6 @@ actual open class Clock {
* ...JVM!
*/
fun onlyJVMFunction(): Double = 2.5
- /**
- * Custom equals function
- */
- override fun equals(other: Any?): Boolean {
- return super.equals(other)
- }
open fun getDayOfTheWeek(): String {
TODO("not implemented")