diff options
Diffstat (limited to 'core/src/test/kotlin/model/PropertyTest.kt')
-rw-r--r-- | core/src/test/kotlin/model/PropertyTest.kt | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/core/src/test/kotlin/model/PropertyTest.kt b/core/src/test/kotlin/model/PropertyTest.kt index 296eaa4c..b3481265 100644 --- a/core/src/test/kotlin/model/PropertyTest.kt +++ b/core/src/test/kotlin/model/PropertyTest.kt @@ -1,15 +1,16 @@ package org.jetbrains.dokka.tests -import org.jetbrains.dokka.Content -import org.jetbrains.dokka.NodeKind -import org.jetbrains.dokka.RefKind +import org.jetbrains.dokka.* +import org.junit.Assert import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Test -class PropertyTest { +abstract class BasePropertyTest(val analysisPlatform: Platform) { + + protected val defaultModelConfig = ModelConfig(analysisPlatform = analysisPlatform) @Test fun valueProperty() { - verifyModel("testdata/properties/valueProperty.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/properties/valueProperty.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("property", name) assertEquals(NodeKind.Property, kind) @@ -22,7 +23,7 @@ class PropertyTest { } @Test fun variableProperty() { - verifyModel("testdata/properties/variableProperty.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/properties/variableProperty.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("property", name) assertEquals(NodeKind.Property, kind) @@ -35,7 +36,7 @@ class PropertyTest { } @Test fun valuePropertyWithGetter() { - verifyModel("testdata/properties/valuePropertyWithGetter.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/properties/valuePropertyWithGetter.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("property", name) assertEquals(NodeKind.Property, kind) @@ -48,7 +49,7 @@ class PropertyTest { } @Test fun variablePropertyWithAccessors() { - verifyModel("testdata/properties/variablePropertyWithAccessors.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/properties/variablePropertyWithAccessors.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals("property", name) assertEquals(NodeKind.Property, kind) @@ -64,21 +65,11 @@ class PropertyTest { } } - @Test fun annotatedProperty() { - verifyModel("testdata/properties/annotatedProperty.kt", withKotlinRuntime = true) { model -> - with(model.members.single().members.single()) { - assertEquals(1, annotations.count()) - with(annotations[0]) { - assertEquals("Strictfp", name) - assertEquals(Content.Empty, content) - assertEquals(NodeKind.Annotation, kind) - } - } - } - } - @Test fun propertyWithReceiver() { - verifyModel("testdata/properties/propertyWithReceiver.kt") { model -> + checkSourceExistsAndVerifyModel( + "testdata/properties/propertyWithReceiver.kt", + defaultModelConfig + ) { model -> with(model.members.single().members.single()) { assertEquals("kotlin.String", name) assertEquals(NodeKind.ExternalClass, kind) @@ -91,7 +82,7 @@ class PropertyTest { } @Test fun propertyOverride() { - verifyModel("testdata/properties/propertyOverride.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/properties/propertyOverride.kt", defaultModelConfig) { model -> with(model.members.single().members.single { it.name == "Bar" }.members.single { it.name == "xyzzy"}) { assertEquals("xyzzy", name) val override = references(RefKind.Override).single().to @@ -102,10 +93,37 @@ class PropertyTest { } @Test fun sinceKotlin() { - verifyModel("testdata/properties/sinceKotlin.kt") { model -> + checkSourceExistsAndVerifyModel("testdata/properties/sinceKotlin.kt", defaultModelConfig) { model -> with(model.members.single().members.single()) { assertEquals(listOf("Kotlin 1.1"), platforms) } } } } + +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("Strictfp", name) + Assert.assertEquals(Content.Empty, content) + Assert.assertEquals(NodeKind.Annotation, kind) + } + } + } + } + +} + +class CommonPropertyTest: BasePropertyTest(Platform.common) {}
\ No newline at end of file |