aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/model
diff options
context:
space:
mode:
authoraleksZubakov <aleks.zubakov@gmail.com>2018-07-12 20:23:02 +0300
committeraleksZubakov <aleks.zubakov@gmail.com>2018-07-12 20:23:02 +0300
commit742be4ef7c024a5ea6023fb684cd24d1898f37e4 (patch)
tree34fc44ef7ee5afdb7a153367d80872f74ace4937 /core/src/test/kotlin/model
parentb4fcc57ab7f335459131ce105924eeaa5fa77375 (diff)
downloaddokka-742be4ef7c024a5ea6023fb684cd24d1898f37e4.tar.gz
dokka-742be4ef7c024a5ea6023fb684cd24d1898f37e4.tar.bz2
dokka-742be4ef7c024a5ea6023fb684cd24d1898f37e4.zip
Test refactoring, add common platform tests
Diffstat (limited to 'core/src/test/kotlin/model')
-rw-r--r--core/src/test/kotlin/model/ClassTest.kt (renamed from core/src/test/kotlin/model/BaseClassTest.kt)49
-rw-r--r--core/src/test/kotlin/model/CommentTest.kt36
-rw-r--r--core/src/test/kotlin/model/FunctionTest.kt23
-rw-r--r--core/src/test/kotlin/model/JSClassTest.kt6
-rw-r--r--core/src/test/kotlin/model/JSFunctionTest.kt8
-rw-r--r--core/src/test/kotlin/model/JSPropertyTest.kt8
-rw-r--r--core/src/test/kotlin/model/JVMClassTest.kt55
-rw-r--r--core/src/test/kotlin/model/JVMFunctionTest.kt29
-rw-r--r--core/src/test/kotlin/model/JVMPropertyTest.kt33
-rw-r--r--core/src/test/kotlin/model/KotlinAsJavaTest.kt9
-rw-r--r--core/src/test/kotlin/model/LinkTest.kt22
-rw-r--r--core/src/test/kotlin/model/PackageTest.kt31
-rw-r--r--core/src/test/kotlin/model/PropertyTest.kt (renamed from core/src/test/kotlin/model/BasePropertyTest.kt)28
13 files changed, 157 insertions, 180 deletions
diff --git a/core/src/test/kotlin/model/BaseClassTest.kt b/core/src/test/kotlin/model/ClassTest.kt
index d48ecb48..b8e58a62 100644
--- a/core/src/test/kotlin/model/BaseClassTest.kt
+++ b/core/src/test/kotlin/model/ClassTest.kt
@@ -4,6 +4,7 @@ import org.jetbrains.dokka.Content
import org.jetbrains.dokka.NodeKind
import org.jetbrains.dokka.Platform
import org.jetbrains.dokka.RefKind
+import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
@@ -267,3 +268,51 @@ abstract class BaseClassTest(val analysisPlatform: Platform) {
}
}
+
+class JSClassTest: BaseClassTest(Platform.js) {}
+
+class JVMClassTest: BaseClassTest(Platform.jvm) {
+ @Test
+ fun annotatedClass() {
+ verifyPackageMember("testdata/classes/annotatedClass.kt", ModelConfig(
+ analysisPlatform = analysisPlatform,
+ withKotlinRuntime = true
+ )
+ ) { cls ->
+ Assert.assertEquals(1, cls.annotations.count())
+ with(cls.annotations[0]) {
+ Assert.assertEquals("Strictfp", name)
+ Assert.assertEquals(Content.Empty, content)
+ Assert.assertEquals(NodeKind.Annotation, kind)
+ }
+ }
+ }
+
+
+ @Test fun javaAnnotationClass() {
+ checkSourceExistsAndVerifyModel(
+ "testdata/classes/javaAnnotationClass.kt",
+ modelConfig = ModelConfig(analysisPlatform = analysisPlatform, withJdk = true)
+ ) { model ->
+ with(model.members.single().members.single()) {
+ Assert.assertEquals(1, annotations.count())
+ with(annotations[0]) {
+ Assert.assertEquals("Retention", name)
+ Assert.assertEquals(Content.Empty, content)
+ Assert.assertEquals(NodeKind.Annotation, kind)
+ with(details[0]) {
+ Assert.assertEquals(NodeKind.Parameter, kind)
+ Assert.assertEquals(1, details.count())
+ with(details[0]) {
+ Assert.assertEquals(NodeKind.Value, kind)
+ Assert.assertEquals("RetentionPolicy.SOURCE", name)
+ }
+ }
+ }
+ }
+ }
+ }
+
+}
+
+class CommonClassTest: BaseClassTest(Platform.common) {} \ No newline at end of file
diff --git a/core/src/test/kotlin/model/CommentTest.kt b/core/src/test/kotlin/model/CommentTest.kt
index a97c55eb..08aa3572 100644
--- a/core/src/test/kotlin/model/CommentTest.kt
+++ b/core/src/test/kotlin/model/CommentTest.kt
@@ -4,10 +4,10 @@ import org.junit.Test
import org.junit.Assert.*
import org.jetbrains.dokka.*
-public class CommentTest {
-
+abstract class BaseCommentTest(val analysisPlatform: Platform) {
+ val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
@Test fun codeBlockComment() {
- checkSourceExistsAndVerifyModel("testdata/comments/codeBlockComment.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/codeBlockComment.kt", defaultModelConfig) { model ->
with(model.members.single().members.first()) {
assertEqualsIgnoringSeparators("""[code lang=brainfuck]
|
@@ -30,7 +30,7 @@ public class CommentTest {
}
@Test fun emptyDoc() {
- checkSourceExistsAndVerifyModel("testdata/comments/emptyDoc.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/emptyDoc.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals(Content.Empty, content)
}
@@ -38,7 +38,7 @@ public class CommentTest {
}
@Test fun emptyDocButComment() {
- checkSourceExistsAndVerifyModel("testdata/comments/emptyDocButComment.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/emptyDocButComment.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals(Content.Empty, content)
}
@@ -46,7 +46,7 @@ public class CommentTest {
}
@Test fun multilineDoc() {
- checkSourceExistsAndVerifyModel("testdata/comments/multilineDoc.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/multilineDoc.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("doc1", content.summary.toTestString())
assertEquals("doc2\ndoc3", content.description.toTestString())
@@ -55,7 +55,7 @@ public class CommentTest {
}
@Test fun multilineDocWithComment() {
- checkSourceExistsAndVerifyModel("testdata/comments/multilineDocWithComment.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/multilineDocWithComment.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("doc1", content.summary.toTestString())
assertEquals("doc2\ndoc3", content.description.toTestString())
@@ -64,7 +64,7 @@ public class CommentTest {
}
@Test fun oneLineDoc() {
- checkSourceExistsAndVerifyModel("testdata/comments/oneLineDoc.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/oneLineDoc.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("doc", content.summary.toTestString())
}
@@ -72,7 +72,7 @@ public class CommentTest {
}
@Test fun oneLineDocWithComment() {
- checkSourceExistsAndVerifyModel("testdata/comments/oneLineDocWithComment.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/oneLineDocWithComment.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("doc", content.summary.toTestString())
}
@@ -80,7 +80,7 @@ public class CommentTest {
}
@Test fun oneLineDocWithEmptyLine() {
- checkSourceExistsAndVerifyModel("testdata/comments/oneLineDocWithEmptyLine.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/oneLineDocWithEmptyLine.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("doc", content.summary.toTestString())
}
@@ -88,7 +88,7 @@ public class CommentTest {
}
@Test fun emptySection() {
- checkSourceExistsAndVerifyModel("testdata/comments/emptySection.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/emptySection.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("Summary", content.summary.toTestString())
assertEquals(1, content.sections.count())
@@ -101,7 +101,7 @@ public class CommentTest {
}
@Test fun quotes() {
- checkSourceExistsAndVerifyModel("testdata/comments/quotes.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/quotes.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("it's \"useful\"", content.summary.toTestString())
}
@@ -109,7 +109,7 @@ public class CommentTest {
}
@Test fun section1() {
- checkSourceExistsAndVerifyModel("testdata/comments/section1.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/section1.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("Summary", content.summary.toTestString())
assertEquals(1, content.sections.count())
@@ -122,7 +122,7 @@ public class CommentTest {
}
@Test fun section2() {
- checkSourceExistsAndVerifyModel("testdata/comments/section2.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/section2.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("Summary", content.summary.toTestString())
assertEquals(2, content.sections.count())
@@ -139,7 +139,7 @@ public class CommentTest {
}
@Test fun multilineSection() {
- checkSourceExistsAndVerifyModel("testdata/comments/multilineSection.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/multilineSection.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("Summary", content.summary.toTestString())
assertEquals(1, content.sections.count())
@@ -153,7 +153,7 @@ line two""", toTestString())
}
@Test fun directive() {
- checkSourceExistsAndVerifyModel("testdata/comments/directive.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/comments/directive.kt", defaultModelConfig) { model ->
with(model.members.single().members.first()) {
assertEquals("Summary", content.summary.toTestString())
with (content.description) {
@@ -184,3 +184,7 @@ line two""", toTestString())
}
}
}
+
+class JSCommentTest: BaseCommentTest(Platform.js)
+class JVMCommentTest: BaseCommentTest(Platform.jvm)
+class CommonCommentTest: BaseCommentTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/model/FunctionTest.kt b/core/src/test/kotlin/model/FunctionTest.kt
index 2704bf65..47685df2 100644
--- a/core/src/test/kotlin/model/FunctionTest.kt
+++ b/core/src/test/kotlin/model/FunctionTest.kt
@@ -4,6 +4,7 @@ import org.jetbrains.dokka.Content
import org.jetbrains.dokka.NodeKind
import org.jetbrains.dokka.Platform
import org.jetbrains.kotlin.analyzer.PlatformAnalysisParameters
+import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
@@ -229,3 +230,25 @@ Documentation""", content.description.toTestString())
}
}
}
+
+class JSFunctionTest: BaseFunctionTest(Platform.js)
+
+class JVMFunctionTest: BaseFunctionTest(Platform.jvm) {
+ @Test
+ fun annotatedFunction() {
+ verifyPackageMember("testdata/functions/annotatedFunction.kt", ModelConfig(
+ analysisPlatform = Platform.jvm,
+ withKotlinRuntime = true
+ )) { func ->
+ Assert.assertEquals(1, func.annotations.count())
+ with(func.annotations[0]) {
+ Assert.assertEquals("Strictfp", name)
+ Assert.assertEquals(Content.Empty, content)
+ Assert.assertEquals(NodeKind.Annotation, kind)
+ }
+ }
+ }
+
+}
+
+class CommonFunctionTest: BaseFunctionTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/model/JSClassTest.kt b/core/src/test/kotlin/model/JSClassTest.kt
deleted file mode 100644
index e39b95cc..00000000
--- a/core/src/test/kotlin/model/JSClassTest.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.jetbrains.dokka.tests.model
-
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.BaseClassTest
-
-class JSClassTest: BaseClassTest(Platform.js) {} \ No newline at end of file
diff --git a/core/src/test/kotlin/model/JSFunctionTest.kt b/core/src/test/kotlin/model/JSFunctionTest.kt
deleted file mode 100644
index f6b987a9..00000000
--- a/core/src/test/kotlin/model/JSFunctionTest.kt
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.jetbrains.dokka.tests.model
-
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.BaseFunctionTest
-
-class JSFunctionTest: BaseFunctionTest(Platform.js) {
-
-} \ No newline at end of file
diff --git a/core/src/test/kotlin/model/JSPropertyTest.kt b/core/src/test/kotlin/model/JSPropertyTest.kt
deleted file mode 100644
index 0193d899..00000000
--- a/core/src/test/kotlin/model/JSPropertyTest.kt
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.jetbrains.dokka.tests.model
-
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.BasePropertyTest
-
-class JSPropertyTest: BasePropertyTest(Platform.js) {
-
-} \ No newline at end of file
diff --git a/core/src/test/kotlin/model/JVMClassTest.kt b/core/src/test/kotlin/model/JVMClassTest.kt
deleted file mode 100644
index 22e23722..00000000
--- a/core/src/test/kotlin/model/JVMClassTest.kt
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.jetbrains.dokka.tests.model
-
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.BaseClassTest
-import org.jetbrains.dokka.tests.ModelConfig
-import org.jetbrains.dokka.tests.checkSourceExistsAndVerifyModel
-import org.jetbrains.dokka.tests.verifyPackageMember
-import org.junit.Assert
-import org.junit.Test
-
-class JVMClassTest: BaseClassTest(Platform.jvm) {
- @Test
- fun annotatedClass() {
- verifyPackageMember("testdata/classes/annotatedClass.kt", ModelConfig(
- analysisPlatform = analysisPlatform,
- withKotlinRuntime = true
- )
- ) { cls ->
- Assert.assertEquals(1, cls.annotations.count())
- with(cls.annotations[0]) {
- Assert.assertEquals("Strictfp", name)
- Assert.assertEquals(Content.Empty, content)
- Assert.assertEquals(NodeKind.Annotation, kind)
- }
- }
- }
-
-
- @Test fun javaAnnotationClass() {
- checkSourceExistsAndVerifyModel(
- "testdata/classes/javaAnnotationClass.kt",
- modelConfig = ModelConfig(analysisPlatform = analysisPlatform, withJdk = true)
- ) { model ->
- with(model.members.single().members.single()) {
- Assert.assertEquals(1, annotations.count())
- with(annotations[0]) {
- Assert.assertEquals("Retention", name)
- Assert.assertEquals(Content.Empty, content)
- Assert.assertEquals(NodeKind.Annotation, kind)
- with(details[0]) {
- Assert.assertEquals(NodeKind.Parameter, kind)
- Assert.assertEquals(1, details.count())
- with(details[0]) {
- Assert.assertEquals(NodeKind.Value, kind)
- Assert.assertEquals("RetentionPolicy.SOURCE", name)
- }
- }
- }
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/core/src/test/kotlin/model/JVMFunctionTest.kt b/core/src/test/kotlin/model/JVMFunctionTest.kt
deleted file mode 100644
index a2fb0d2a..00000000
--- a/core/src/test/kotlin/model/JVMFunctionTest.kt
+++ /dev/null
@@ -1,29 +0,0 @@
-package org.jetbrains.dokka.tests.model
-
-import com.sun.tools.javac.util.BaseFileManager
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.BaseFunctionTest
-import org.jetbrains.dokka.tests.ModelConfig
-import org.jetbrains.dokka.tests.verifyPackageMember
-import org.junit.Assert
-import org.junit.Test
-
-class JVMFunctionTest: BaseFunctionTest(Platform.jvm) {
- @Test
- fun annotatedFunction() {
- verifyPackageMember("testdata/functions/annotatedFunction.kt", ModelConfig(
- analysisPlatform = Platform.jvm,
- withKotlinRuntime = true
- )) { func ->
- Assert.assertEquals(1, func.annotations.count())
- with(func.annotations[0]) {
- Assert.assertEquals("Strictfp", name)
- Assert.assertEquals(Content.Empty, content)
- Assert.assertEquals(NodeKind.Annotation, kind)
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/core/src/test/kotlin/model/JVMPropertyTest.kt b/core/src/test/kotlin/model/JVMPropertyTest.kt
deleted file mode 100644
index 182dedbe..00000000
--- a/core/src/test/kotlin/model/JVMPropertyTest.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.jetbrains.dokka.tests.model
-
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.Platform
-import org.jetbrains.dokka.tests.BasePropertyTest
-import org.jetbrains.dokka.tests.ModelConfig
-import org.jetbrains.dokka.tests.checkSourceExistsAndVerifyModel
-import org.junit.Assert
-import org.junit.Test
-
-class JVMPropertyTest : BasePropertyTest(Platform.jvm) {
- @Test
- fun annotatedProperty() {
- checkSourceExistsAndVerifyModel(
- "testdata/properties/annotatedProperty.kt",
- modelConfig = ModelConfig(
- analysisPlatform = analysisPlatform,
- withKotlinRuntime = true
- )
- ) { model ->
- with(model.members.single().members.single()) {
- Assert.assertEquals(1, annotations.count())
- with(annotations[0]) {
- Assert.assertEquals("Volatile", name)
- Assert.assertEquals(Content.Empty, content)
- Assert.assertEquals(NodeKind.Annotation, kind)
- }
- }
- }
- }
-
-} \ No newline at end of file
diff --git a/core/src/test/kotlin/model/KotlinAsJavaTest.kt b/core/src/test/kotlin/model/KotlinAsJavaTest.kt
index 1d95556f..f6f0aa20 100644
--- a/core/src/test/kotlin/model/KotlinAsJavaTest.kt
+++ b/core/src/test/kotlin/model/KotlinAsJavaTest.kt
@@ -7,8 +7,6 @@ import org.junit.Test
import org.junit.Assert.assertEquals
class KotlinAsJavaTest {
- private val defaultModelConfig = ModelConfig (analysisPlatform = Platform.jvm)
-
@Test fun function() {
verifyModelAsJava("testdata/functions/function.kt") { model ->
val pkg = model.members.single()
@@ -33,14 +31,13 @@ class KotlinAsJavaTest {
}
fun verifyModelAsJava(source: String,
- withJdk: Boolean = false,
- withKotlinRuntime: Boolean = false,
+ modelConfig: ModelConfig = ModelConfig(),
verifier: (DocumentationModule) -> Unit) {
checkSourceExistsAndVerifyModel(
source,
modelConfig = ModelConfig(
- withJdk = withJdk,
- withKotlinRuntime = withKotlinRuntime,
+ withJdk = modelConfig.withJdk,
+ withKotlinRuntime = modelConfig.withKotlinRuntime,
format = "html-as-java",
analysisPlatform = Platform.jvm),
verifier = verifier
diff --git a/core/src/test/kotlin/model/LinkTest.kt b/core/src/test/kotlin/model/LinkTest.kt
index d7283bae..9b2f9f0d 100644
--- a/core/src/test/kotlin/model/LinkTest.kt
+++ b/core/src/test/kotlin/model/LinkTest.kt
@@ -3,12 +3,14 @@ package org.jetbrains.dokka.tests
import org.jetbrains.dokka.ContentBlock
import org.jetbrains.dokka.ContentNodeLazyLink
import org.jetbrains.dokka.NodeKind
+import org.jetbrains.dokka.Platform
import org.junit.Assert.assertEquals
import org.junit.Test
-class LinkTest {
+abstract class BaseLinkTest(val analysisPlatform: Platform) {
+ private val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
@Test fun linkToSelf() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToSelf.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/links/linkToSelf.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("Foo", name)
assertEquals(NodeKind.Class, kind)
@@ -18,7 +20,7 @@ class LinkTest {
}
@Test fun linkToMember() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToMember.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/links/linkToMember.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("Foo", name)
assertEquals(NodeKind.Class, kind)
@@ -28,7 +30,7 @@ class LinkTest {
}
@Test fun linkToConstantWithUnderscores() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToConstantWithUnderscores.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/links/linkToConstantWithUnderscores.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("Foo", name)
assertEquals(NodeKind.Class, kind)
@@ -38,7 +40,7 @@ class LinkTest {
}
@Test fun linkToQualifiedMember() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToQualifiedMember.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/links/linkToQualifiedMember.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("Foo", name)
assertEquals(NodeKind.Class, kind)
@@ -48,7 +50,7 @@ class LinkTest {
}
@Test fun linkToParam() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToParam.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/links/linkToParam.kt", defaultModelConfig) { model ->
with(model.members.single().members.single()) {
assertEquals("Foo", name)
assertEquals(NodeKind.Function, kind)
@@ -58,7 +60,7 @@ class LinkTest {
}
@Test fun linkToPackage() {
- checkSourceExistsAndVerifyModel("testdata/links/linkToPackage.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/links/linkToPackage.kt", defaultModelConfig) { model ->
val packageNode = model.members.single()
with(packageNode) {
assertEquals(this.name, "test.magic")
@@ -72,4 +74,8 @@ class LinkTest {
}
}
-} \ No newline at end of file
+}
+
+class JSLinkTest: BaseLinkTest(Platform.js)
+class JVMLinkTest: BaseLinkTest(Platform.jvm)
+class CommonLinkTest: BaseLinkTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/model/PackageTest.kt b/core/src/test/kotlin/model/PackageTest.kt
index bc8a0e0d..80a2fd56 100644
--- a/core/src/test/kotlin/model/PackageTest.kt
+++ b/core/src/test/kotlin/model/PackageTest.kt
@@ -1,15 +1,14 @@
package org.jetbrains.dokka.tests
-import org.jetbrains.dokka.Content
-import org.jetbrains.dokka.NodeKind
-import org.jetbrains.dokka.PackageOptionsImpl
+import org.jetbrains.dokka.*
import org.jetbrains.kotlin.config.KotlinSourceRoot
import org.junit.Assert.*
import org.junit.Test
-public class PackageTest {
+abstract class BasePackageTest(val analysisPlatform: Platform) {
+ val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform)
@Test fun rootPackage() {
- checkSourceExistsAndVerifyModel("testdata/packages/rootPackage.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/packages/rootPackage.kt", defaultModelConfig) { model ->
with(model.members.single()) {
assertEquals(NodeKind.Package, kind)
assertEquals("", name)
@@ -22,7 +21,7 @@ public class PackageTest {
}
@Test fun simpleNamePackage() {
- checkSourceExistsAndVerifyModel("testdata/packages/simpleNamePackage.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/packages/simpleNamePackage.kt", defaultModelConfig) { model ->
with(model.members.single()) {
assertEquals(NodeKind.Package, kind)
assertEquals("simple", name)
@@ -35,7 +34,7 @@ public class PackageTest {
}
@Test fun dottedNamePackage() {
- checkSourceExistsAndVerifyModel("testdata/packages/dottedNamePackage.kt") { model ->
+ checkSourceExistsAndVerifyModel("testdata/packages/dottedNamePackage.kt", defaultModelConfig) { model ->
with(model.members.single()) {
assertEquals(NodeKind.Package, kind)
assertEquals("dot.name", name)
@@ -53,7 +52,8 @@ public class PackageTest {
roots = arrayOf(
KotlinSourceRoot("testdata/packages/dottedNamePackage.kt"),
KotlinSourceRoot("testdata/packages/simpleNamePackage.kt")
- )
+ ),
+ analysisPlatform = analysisPlatform
)
) { model ->
assertEquals(2, model.members.count())
@@ -81,7 +81,8 @@ public class PackageTest {
roots = arrayOf(
KotlinSourceRoot("testdata/packages/simpleNamePackage.kt"),
KotlinSourceRoot("testdata/packages/simpleNamePackage2.kt")
- )
+ ),
+ analysisPlatform = analysisPlatform
)
) { model ->
assertEquals(1, model.members.count())
@@ -98,7 +99,10 @@ public class PackageTest {
@Test fun classAtPackageLevel() {
verifyModel(
- ModelConfig(roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt")))
+ ModelConfig(
+ roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt")),
+ analysisPlatform = analysisPlatform
+ )
) { model ->
assertEquals(1, model.members.count())
with(model.members.elementAt(0)) {
@@ -118,7 +122,8 @@ public class PackageTest {
roots = arrayOf(KotlinSourceRoot("testdata/packages/classInPackage.kt")),
perPackageOptions = listOf(
PackageOptionsImpl(prefix = "simple.name", suppress = true)
- )
+ ),
+ analysisPlatform = analysisPlatform
)
) { model ->
assertEquals(1, model.members.count())
@@ -133,3 +138,7 @@ public class PackageTest {
}
}
}
+
+class JSPackageTest : BasePackageTest(Platform.js)
+class JVMPackageTest : BasePackageTest(Platform.jvm)
+class CommonPackageTest : BasePackageTest(Platform.common) \ No newline at end of file
diff --git a/core/src/test/kotlin/model/BasePropertyTest.kt b/core/src/test/kotlin/model/PropertyTest.kt
index c88fe702..a41ab5a3 100644
--- a/core/src/test/kotlin/model/BasePropertyTest.kt
+++ b/core/src/test/kotlin/model/PropertyTest.kt
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.tests
import org.jetbrains.dokka.*
+import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
@@ -99,3 +100,30 @@ abstract class BasePropertyTest(val analysisPlatform: Platform) {
}
}
}
+
+class JSPropertyTest: BasePropertyTest(Platform.js) {}
+
+class JVMPropertyTest : BasePropertyTest(Platform.jvm) {
+ @Test
+ fun annotatedProperty() {
+ checkSourceExistsAndVerifyModel(
+ "testdata/properties/annotatedProperty.kt",
+ modelConfig = ModelConfig(
+ analysisPlatform = analysisPlatform,
+ withKotlinRuntime = true
+ )
+ ) { model ->
+ with(model.members.single().members.single()) {
+ Assert.assertEquals(1, annotations.count())
+ with(annotations[0]) {
+ Assert.assertEquals("Volatile", name)
+ Assert.assertEquals(Content.Empty, content)
+ Assert.assertEquals(NodeKind.Annotation, kind)
+ }
+ }
+ }
+ }
+
+}
+
+class CommonPropertyTest: BasePropertyTest(Platform.common) {} \ No newline at end of file