aboutsummaryrefslogtreecommitdiff
path: root/core/src/test/kotlin/javadoc/JavadocTest.kt
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/kotlin/javadoc/JavadocTest.kt')
-rw-r--r--core/src/test/kotlin/javadoc/JavadocTest.kt46
1 files changed, 46 insertions, 0 deletions
diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt
index 34b0b7a5..b18dacca 100644
--- a/core/src/test/kotlin/javadoc/JavadocTest.kt
+++ b/core/src/test/kotlin/javadoc/JavadocTest.kt
@@ -7,6 +7,7 @@ import org.jetbrains.dokka.tests.assertEqualsIgnoringSeparators
import org.jetbrains.dokka.tests.verifyModel
import org.junit.Assert.*
import org.junit.Test
+import java.lang.reflect.Modifier.*
class JavadocTest {
@Test fun testTypes() {
@@ -177,6 +178,51 @@ class JavadocTest {
}
}
+ @Test
+ fun shouldHaveValidVisibilityModifiers() {
+ verifyJavadoc("testdata/javadoc/visibilityModifiers.kt", withKotlinRuntime = true) { doc ->
+ val classDoc = doc.classNamed("foo.Apple")!!
+ val methods = classDoc.methods()
+
+ val getName = methods[0]
+ val setName = methods[1]
+ val getWeight = methods[2]
+ val setWeight = methods[3]
+ val getRating = methods[4]
+ val setRating = methods[5]
+ val getCode = methods[6]
+ val color = classDoc.fields()[3]
+ val code = classDoc.fields()[4]
+
+ assertTrue(getName.isProtected)
+ assertEquals(PROTECTED, getName.modifierSpecifier())
+ assertTrue(setName.isProtected)
+ assertEquals(PROTECTED, setName.modifierSpecifier())
+
+ assertTrue(getWeight.isPublic)
+ assertEquals(PUBLIC, getWeight.modifierSpecifier())
+ assertTrue(setWeight.isPublic)
+ assertEquals(PUBLIC, setWeight.modifierSpecifier())
+
+ assertTrue(getRating.isPublic)
+ assertEquals(PUBLIC, getRating.modifierSpecifier())
+ assertTrue(setRating.isPublic)
+ assertEquals(PUBLIC, setRating.modifierSpecifier())
+
+ assertTrue(getCode.isPublic)
+ assertEquals(PUBLIC or STATIC, getCode.modifierSpecifier())
+
+ assertEquals(methods.size, 7)
+
+ assertTrue(color.isPrivate)
+ assertEquals(PRIVATE, color.modifierSpecifier())
+
+ assertTrue(code.isPrivate)
+ assertTrue(code.isStatic)
+ assertEquals(PRIVATE or STATIC, code.modifierSpecifier())
+ }
+ }
+
private fun verifyJavadoc(name: String,
withJdk: Boolean = false,
withKotlinRuntime: Boolean = false,