From 7fa258873eab770577879e9721c0864449ba1114 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Thu, 16 Feb 2017 21:28:16 +0300 Subject: Dokka now can detect and recognize SinceKotlin --- core/src/test/kotlin/TestAPI.kt | 7 ++++++- core/src/test/kotlin/format/HtmlFormatTest.kt | 4 ++++ core/src/test/kotlin/format/MarkdownFormatTest.kt | 6 +++++- core/src/test/kotlin/model/ClassTest.kt | 11 ++++++++++- core/src/test/kotlin/model/FunctionTest.kt | 11 ++++++++++- core/src/test/kotlin/model/PropertyTest.kt | 11 ++++++++++- core/src/test/kotlin/model/TypeAliasTest.kt | 10 ++++++++++ 7 files changed, 55 insertions(+), 5 deletions(-) (limited to 'core/src/test') diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt index 108c5bbf..61eab562 100644 --- a/core/src/test/kotlin/TestAPI.kt +++ b/core/src/test/kotlin/TestAPI.kt @@ -141,7 +141,12 @@ private fun verifyModelOutput(it: DocumentationModule, outputGenerator(it, output) val ext = outputExtension.removePrefix(".") val path = sourcePath - val expectedOutput = File(path.replaceAfterLast(".", ext, path + "." + ext)).readText() + val expectedFileContent = File(path.replaceAfterLast(".", ext, path + "." + ext)).readText() + val expectedOutput = + if (ext.equals("html", true)) + expectedFileContent.lines().joinToString(separator = "\n", transform = String::trim) + else + expectedFileContent assertEqualsIgnoringSeparators(expectedOutput, output.toString()) } diff --git a/core/src/test/kotlin/format/HtmlFormatTest.kt b/core/src/test/kotlin/format/HtmlFormatTest.kt index 4b4eff59..1816c075 100644 --- a/core/src/test/kotlin/format/HtmlFormatTest.kt +++ b/core/src/test/kotlin/format/HtmlFormatTest.kt @@ -138,6 +138,10 @@ class HtmlFormatTest { verifyHtmlNode("functionalTypeWithNamedParameters") } + @Test fun sinceKotlin() { + verifyHtmlNode("sinceKotlin") + } + private fun verifyHtmlNode(fileName: String, withKotlinRuntime: Boolean = false) { verifyHtmlNodes(fileName, withKotlinRuntime) { model -> model.members.single().members } } diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt index f870d898..4dd01a20 100644 --- a/core/src/test/kotlin/format/MarkdownFormatTest.kt +++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt @@ -4,7 +4,6 @@ import org.jetbrains.dokka.DocumentationModule import org.jetbrains.dokka.DocumentationNode import org.jetbrains.dokka.KotlinLanguageService import org.jetbrains.dokka.MarkdownFormatService -import org.junit.Ignore import org.junit.Test class MarkdownFormatTest { @@ -241,6 +240,11 @@ class MarkdownFormatTest { verifyMarkdownPackage("suspendParam") } + @Test fun sinceKotlin() { + verifyMarkdownNode("sinceKotlin") + verifyMarkdownPackage("sinceKotlin") + } + private fun verifyMarkdownPackage(fileName: String, withKotlinRuntime: Boolean = false) { verifyOutput("testdata/format/$fileName.kt", ".package.md", withKotlinRuntime = withKotlinRuntime) { model, output -> markdownService.createOutputBuilder(output, tempLocation).appendNodes(model.members) diff --git a/core/src/test/kotlin/model/ClassTest.kt b/core/src/test/kotlin/model/ClassTest.kt index d50a3624..b6ac7126 100644 --- a/core/src/test/kotlin/model/ClassTest.kt +++ b/core/src/test/kotlin/model/ClassTest.kt @@ -6,8 +6,9 @@ import org.jetbrains.dokka.RefKind import org.junit.Test import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue +import kotlin.test.assertNotNull -public class ClassTest { +class ClassTest { @Test fun emptyClass() { verifyModel("testdata/classes/emptyClass.kt") { model -> with(model.members.single().members.single()) { @@ -272,4 +273,12 @@ public class ClassTest { } } } + + @Test fun sinceKotlin() { + verifyModel("testdata/classes/sinceKotlin.kt") { model -> + with(model.members.single().members.single()) { + assertNotNull(sinceKotlin) + } + } + } } diff --git a/core/src/test/kotlin/model/FunctionTest.kt b/core/src/test/kotlin/model/FunctionTest.kt index 4cced562..8cf6b14a 100644 --- a/core/src/test/kotlin/model/FunctionTest.kt +++ b/core/src/test/kotlin/model/FunctionTest.kt @@ -5,8 +5,9 @@ import org.jetbrains.dokka.NodeKind import org.junit.Test import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue +import kotlin.test.assertNotNull -public class FunctionTest { +class FunctionTest { @Test fun function() { verifyModel("testdata/functions/function.kt") { model -> with(model.members.single().members.single()) { @@ -224,4 +225,12 @@ Documentation""", content.description.toTestString()) } } } + + @Test fun sinceKotlin() { + verifyModel("testdata/functions/sinceKotlin.kt") { model -> + with(model.members.single().members.single()) { + assertNotNull(sinceKotlin) + } + } + } } diff --git a/core/src/test/kotlin/model/PropertyTest.kt b/core/src/test/kotlin/model/PropertyTest.kt index cdf44c03..1dbb102a 100644 --- a/core/src/test/kotlin/model/PropertyTest.kt +++ b/core/src/test/kotlin/model/PropertyTest.kt @@ -6,8 +6,9 @@ import org.jetbrains.dokka.RefKind import org.junit.Test import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue +import kotlin.test.assertNotNull -public class PropertyTest { +class PropertyTest { @Test fun valueProperty() { verifyModel("testdata/properties/valueProperty.kt") { model -> with(model.members.single().members.single()) { @@ -100,4 +101,12 @@ public class PropertyTest { } } } + + @Test fun sinceKotlin() { + verifyModel("testdata/properties/sinceKotlin.kt") { model -> + with(model.members.single().members.single()) { + assertNotNull(sinceKotlin) + } + } + } } diff --git a/core/src/test/kotlin/model/TypeAliasTest.kt b/core/src/test/kotlin/model/TypeAliasTest.kt index 812fd9dc..dbb15be4 100644 --- a/core/src/test/kotlin/model/TypeAliasTest.kt +++ b/core/src/test/kotlin/model/TypeAliasTest.kt @@ -4,6 +4,7 @@ import junit.framework.TestCase.assertEquals import org.jetbrains.dokka.Content import org.jetbrains.dokka.NodeKind import org.junit.Test +import kotlin.test.assertNotNull class TypeAliasTest { @Test @@ -120,4 +121,13 @@ class TypeAliasTest { } } } + + @Test + fun sinceKotlin() { + verifyModel("testdata/typealias/sinceKotlin.kt") { model -> + with(model.members.single().members.single()) { + assertNotNull(sinceKotlin) + } + } + } } \ No newline at end of file -- cgit