aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/javadoc/JavadocTest.kt
diff options
context:
space:
mode:
authorEugene Petrenko <eugene.petrenko@gmail.com>2018-09-11 14:03:29 +0300
committerEugene Petrenko <eugene.petrenko@gmail.com>2018-09-11 14:03:29 +0300
commita54070f5db04d05b48c369b211efe044fbc02a8d (patch)
treeaac5889906f49f68c39e1416ea39d4d19bad008e /core/src/test/kotlin/javadoc/JavadocTest.kt
parente29f1c966056b0f7ee31dd9bd7d55f9e526fa7fe (diff)
parent0df19264ccae3d294946caf634ee15eea0c4fe4a (diff)
downloaddokka-a54070f5db04d05b48c369b211efe044fbc02a8d.tar.gz
dokka-a54070f5db04d05b48c369b211efe044fbc02a8d.tar.bz2
dokka-a54070f5db04d05b48c369b211efe044fbc02a8d.zip
Merge remote-tracking branch 'zub/dev-multiplatf' into kotlin-website-jonnyzzz
Diffstat (limited to 'core/src/test/kotlin/javadoc/JavadocTest.kt')
-rw-r--r--core/src/test/kotlin/javadoc/JavadocTest.kt75
1 files changed, 57 insertions, 18 deletions
diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt
index 45c45aa4..7976fccc 100644
--- a/core/src/test/kotlin/javadoc/JavadocTest.kt
+++ b/core/src/test/kotlin/javadoc/JavadocTest.kt
@@ -3,14 +3,18 @@ package org.jetbrains.dokka.javadoc
import com.sun.javadoc.Tag
import com.sun.javadoc.Type
import org.jetbrains.dokka.DokkaConsoleLogger
+import org.jetbrains.dokka.Platform
+import org.jetbrains.dokka.tests.ModelConfig
import org.jetbrains.dokka.tests.assertEqualsIgnoringSeparators
-import org.jetbrains.dokka.tests.verifyModel
+import org.jetbrains.dokka.tests.checkSourceExistsAndVerifyModel
import org.junit.Assert.*
import org.junit.Test
class JavadocTest {
+ val defaultModelConfig = ModelConfig(analysisPlatform = Platform.jvm)
+
@Test fun testTypes() {
- verifyJavadoc("testdata/javadoc/types.kt", withJdk = true) { doc ->
+ verifyJavadoc("testdata/javadoc/types.kt", ModelConfig(analysisPlatform = Platform.jvm, withJdk = true)) { doc ->
val classDoc = doc.classNamed("foo.TypesKt")!!
val method = classDoc.methods().find { it.name() == "foo" }!!
@@ -26,7 +30,7 @@ class JavadocTest {
}
@Test fun testObject() {
- verifyJavadoc("testdata/javadoc/obj.kt") { doc ->
+ verifyJavadoc("testdata/javadoc/obj.kt", defaultModelConfig) { doc ->
val classDoc = doc.classNamed("foo.O")
assertNotNull(classDoc)
@@ -39,7 +43,10 @@ class JavadocTest {
}
@Test fun testException() {
- verifyJavadoc("testdata/javadoc/exception.kt", withKotlinRuntime = true) { doc ->
+ verifyJavadoc(
+ "testdata/javadoc/exception.kt",
+ ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
+ ) { doc ->
val classDoc = doc.classNamed("foo.MyException")!!
val member = classDoc.methods().find { it.name() == "foo" }
assertEquals(classDoc, member!!.containingClass())
@@ -47,7 +54,10 @@ class JavadocTest {
}
@Test fun testByteArray() {
- verifyJavadoc("testdata/javadoc/bytearr.kt", withKotlinRuntime = true) { doc ->
+ verifyJavadoc(
+ "testdata/javadoc/bytearr.kt",
+ ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
+ ) { doc ->
val classDoc = doc.classNamed("foo.ByteArray")!!
assertNotNull(classDoc.asClassDoc())
@@ -57,7 +67,10 @@ class JavadocTest {
}
@Test fun testStringArray() {
- verifyJavadoc("testdata/javadoc/stringarr.kt", withKotlinRuntime = true) { doc ->
+ verifyJavadoc(
+ "testdata/javadoc/stringarr.kt",
+ ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
+ ) { doc ->
val classDoc = doc.classNamed("foo.Foo")!!
assertNotNull(classDoc.asClassDoc())
@@ -70,7 +83,10 @@ class JavadocTest {
}
@Test fun testJvmName() {
- verifyJavadoc("testdata/javadoc/jvmname.kt", withKotlinRuntime = true) { doc ->
+ verifyJavadoc(
+ "testdata/javadoc/jvmname.kt",
+ ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
+ ) { doc ->
val classDoc = doc.classNamed("foo.Apple")!!
assertNotNull(classDoc.asClassDoc())
@@ -80,7 +96,10 @@ class JavadocTest {
}
@Test fun testLinkWithParam() {
- verifyJavadoc("testdata/javadoc/paramlink.kt", withKotlinRuntime = true) { doc ->
+ verifyJavadoc(
+ "testdata/javadoc/paramlink.kt",
+ ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
+ ) { doc ->
val classDoc = doc.classNamed("demo.Apple")!!
assertNotNull(classDoc.asClassDoc())
val tags = classDoc.inlineTags().filterIsInstance<SeeTagAdapter>()
@@ -91,7 +110,10 @@ class JavadocTest {
}
@Test fun testInternalVisibility() {
- verifyJavadoc("testdata/javadoc/internal.kt", withKotlinRuntime = true, includeNonPublic = false) { doc ->
+ verifyJavadoc(
+ "testdata/javadoc/internal.kt",
+ ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true, includeNonPublic = false)
+ ) { doc ->
val classDoc = doc.classNamed("foo.Person")!!
val constructors = classDoc.constructors()
assertEquals(1, constructors.size)
@@ -100,7 +122,10 @@ class JavadocTest {
}
@Test fun testSuppress() {
- verifyJavadoc("testdata/javadoc/suppress.kt", withKotlinRuntime = true) { doc ->
+ verifyJavadoc(
+ "testdata/javadoc/suppress.kt",
+ ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
+ ) { doc ->
assertNull(doc.classNamed("Some"))
assertNull(doc.classNamed("SomeAgain"))
assertNull(doc.classNamed("Interface"))
@@ -111,7 +136,10 @@ class JavadocTest {
}
@Test fun testTypeAliases() {
- verifyJavadoc("testdata/javadoc/typealiases.kt", withKotlinRuntime = true) { doc ->
+ verifyJavadoc(
+ "testdata/javadoc/typealiases.kt",
+ ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
+ ) { doc ->
assertNull(doc.classNamed("B"))
assertNull(doc.classNamed("D"))
@@ -126,7 +154,10 @@ class JavadocTest {
}
@Test fun testKDocKeywordsOnMethod() {
- verifyJavadoc("testdata/javadoc/kdocKeywordsOnMethod.kt", withKotlinRuntime = true) { doc ->
+ verifyJavadoc(
+ "testdata/javadoc/kdocKeywordsOnMethod.kt",
+ ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
+ ) { doc ->
val method = doc.classNamed("KdocKeywordsOnMethodKt")!!.methods()[0]
assertEquals("@return [ContentText(text=value of a)]", method.tags("return").first().text())
assertEquals("@param a [ContentText(text=Some string)]", method.paramTags().first().text())
@@ -136,7 +167,10 @@ class JavadocTest {
@Test
fun testBlankLineInsideCodeBlock() {
- verifyJavadoc("testdata/javadoc/blankLineInsideCodeBlock.kt", withKotlinRuntime = true) { doc ->
+ verifyJavadoc(
+ "testdata/javadoc/blankLineInsideCodeBlock.kt",
+ ModelConfig(analysisPlatform = Platform.jvm, withKotlinRuntime = true)
+ ) { doc ->
val method = doc.classNamed("BlankLineInsideCodeBlockKt")!!.methods()[0]
val text = method.inlineTags().joinToString(separator = "", transform = Tag::text)
assertEqualsIgnoringSeparators("""
@@ -153,7 +187,7 @@ class JavadocTest {
@Test
fun testCompanionMethodReference() {
- verifyJavadoc("testdata/javadoc/companionMethodReference.kt") { doc ->
+ verifyJavadoc("testdata/javadoc/companionMethodReference.kt", defaultModelConfig) { doc ->
val classDoc = doc.classNamed("foo.TestClass")!!
val tag = classDoc.inlineTags().filterIsInstance<SeeMethodTagAdapter>().first()
assertEquals("TestClass.Companion", tag.referencedClassName())
@@ -162,12 +196,17 @@ class JavadocTest {
}
private fun verifyJavadoc(name: String,
- withJdk: Boolean = false,
- withKotlinRuntime: Boolean = false,
- includeNonPublic: Boolean = true,
+ modelConfig: ModelConfig = ModelConfig(),
callback: (ModuleNodeAdapter) -> Unit) {
- verifyModel(name, format = "javadoc", withJdk = withJdk, withKotlinRuntime = withKotlinRuntime, includeNonPublic = includeNonPublic) { model ->
+ checkSourceExistsAndVerifyModel(name,
+ ModelConfig(
+ analysisPlatform = Platform.jvm,
+ format = "javadoc",
+ withJdk = modelConfig.withJdk,
+ withKotlinRuntime = modelConfig.withKotlinRuntime,
+ includeNonPublic = modelConfig.includeNonPublic
+ )) { model ->
val doc = ModuleNodeAdapter(model, StandardReporter(DokkaConsoleLogger), "")
callback(doc)
}